public class XMLHTTPRequest extends MSXMLScriptable
Modifier and Type | Field and Description |
---|---|
static int |
STATE_DONE
All the data has been received; the complete data is available in responseBody and responseText.
|
static int |
STATE_HEADERS_RECEIVED
The send() method has been called, but the status and headers are not yet available.
|
static int |
STATE_LOADING
Some data has been received.
|
static int |
STATE_OPENED
The object has been created, but the send() method has not been called.
|
static int |
STATE_UNSENT
The object has been created, but not initialized (the open() method has not been called).
|
Constructor and Description |
---|
XMLHTTPRequest()
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Cancels the current HTTP request.
|
Object |
get(String name,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Gets a named property from the object.
|
String |
getAllResponseHeaders()
Returns the values of all the HTTP headers.
|
Object |
getOnreadystatechange()
Returns the event handler to be called when the
readyState property changes. |
int |
getReadyState()
Returns the state of the request.
|
String |
getResponseHeader(String header)
Retrieves the value of an HTTP header from the response body.
|
String |
getResponseText()
Returns the response entity body as a string.
|
Object |
getResponseXML()
Returns the parsed response entity body.
|
int |
getStatus()
Returns the HTTP status code returned by a request.
|
String |
getStatusText()
Returns the HTTP response line status.
|
void |
open(String method,
Object url,
Object asyncParam,
Object user,
Object password)
Initializes the request and specifies the method, URL, and authentication information for the request.
|
void |
put(String name,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start,
Object value) |
void |
send(Object body)
Sends an HTTP request to the server and receives a response.
|
void |
setOnreadystatechange(net.sourceforge.htmlunit.corejs.javascript.Function stateChangeHandler)
Sets the event handler to be called when the
readyState property changes. |
void |
setRequestHeader(String name,
String value)
Sets the specified header to the specified value.
|
getClassName, getEnvironment, getPrototype, isReadOnlySettable, makeScriptableFor, setEnvironment, setParentScope
clone, equivalentValues, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, setClassName
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public static final int STATE_UNSENT
public static final int STATE_OPENED
public static final int STATE_HEADERS_RECEIVED
public static final int STATE_LOADING
public static final int STATE_DONE
public Object getOnreadystatechange()
readyState
property changes.public void setOnreadystatechange(net.sourceforge.htmlunit.corejs.javascript.Function stateChangeHandler)
readyState
property changes.stateChangeHandler
- the event handler to be called when the readyState property changespublic int getReadyState()
public String getResponseText()
public Object getResponseXML()
public int getStatus()
public String getStatusText()
public void abort()
public String getAllResponseHeaders()
public String getResponseHeader(String header)
header
- the case-insensitive header namepublic void open(String method, Object url, Object asyncParam, Object user, Object password)
method
- the HTTP method used to open the connection, such as GET, POST, PUT, or PROPFIND;
for XMLHTTP, this parameter is not case-sensitive; the verbs TRACE and TRACK are not allowed.url
- the requested URL; this can be either an absolute URL or a relative URLasyncParam
- indicator of whether the call is asynchronous; the default is true
(the call
returns immediately); if set to true
, attach an onreadystatechange
property
callback so that you can tell when the send
call has completeduser
- the name of the user for authenticationpassword
- the password for authenticationpublic void send(Object body)
body
- the body of the message being sent with the request.public void setRequestHeader(String name, String value)
open
method must be called before this method, or an error will occur.name
- the header name to setvalue
- the value of the headerpublic Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
SimpleScriptable.getWithPreemption(String)
.
get
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
get
in class SimpleScriptable
public void put(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start, Object value)
put
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
put
in class HtmlUnitScriptable
Copyright © 2002–2020 Gargoyle Software Inc.. All rights reserved.