Package org.htmlunit
Class StringWebResponse
- java.lang.Object
-
- org.htmlunit.WebResponse
-
- org.htmlunit.StringWebResponse
-
- All Implemented Interfaces:
java.io.Serializable
public class StringWebResponse extends WebResponse
A simple WebResponse created from a string. Content is assumed to be of typetext/html
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
fromJavascript_
-
Constructor Summary
Constructors Constructor Description StringWebResponse(java.lang.String content, java.net.URL originatingURL)
Creates an instance associated with the specified originating URL.StringWebResponse(java.lang.String content, java.nio.charset.Charset charset, java.net.URL originatingURL)
Creates an instance associated with the specified originating URL.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static WebRequest
buildWebRequest(java.net.URL originatingURL, java.nio.charset.Charset charset)
private static WebResponseData
getWebResponseData(java.lang.String contentString, java.nio.charset.Charset charset)
Helper method for constructors.boolean
isFromJavascript()
Returns the fromJavascript property.void
setFromJavascript(boolean fromJavascript)
Sets the fromJavascript_ property.-
Methods inherited from class org.htmlunit.WebResponse
cleanUp, defaultCharsetUtf8, getBlockReason, getContentAsStream, getContentAsStreamWithBomIfApplicable, getContentAsString, getContentAsString, getContentCharset, getContentCharsetOrNull, getContentLength, getContentType, getHeaderContentCharset, getLoadTime, getResponseHeaders, getResponseHeaderValue, getStatusCode, getStatusMessage, getWebRequest, isSuccess, isSuccessOrUseProxy, isSuccessOrUseProxyOrNotModified, markAsBlocked, wasBlocked, wasContentCharsetTentative
-
-
-
-
Constructor Detail
-
StringWebResponse
public StringWebResponse(java.lang.String content, java.net.URL originatingURL)
Creates an instance associated with the specified originating URL.- Parameters:
content
- the content to returnoriginatingURL
- the URL that this should be associated with
-
StringWebResponse
public StringWebResponse(java.lang.String content, java.nio.charset.Charset charset, java.net.URL originatingURL)
Creates an instance associated with the specified originating URL.- Parameters:
content
- the content to returncharset
- the charset used to convert the contentoriginatingURL
- the URL that this should be associated with
-
-
Method Detail
-
getWebResponseData
private static WebResponseData getWebResponseData(java.lang.String contentString, java.nio.charset.Charset charset)
Helper method for constructors. Converts the specified string intoWebResponseData
with other defaults specified.- Parameters:
contentString
- the string to be converted to aWebResponseData
- Returns:
- a simple
WebResponseData
with defaults specified
-
buildWebRequest
private static WebRequest buildWebRequest(java.net.URL originatingURL, java.nio.charset.Charset charset)
-
isFromJavascript
public boolean isFromJavascript()
Returns the fromJavascript property. This is true, if the response was created from javascript (usually document.write).- Returns:
- the from fromJavascript_
-
setFromJavascript
public void setFromJavascript(boolean fromJavascript)
Sets the fromJavascript_ property. Set this to true, if the response was created from javascript (usually document.write).- Parameters:
fromJavascript
- the new fromJavascript
-
-