java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.fetch.Response
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
A JavaScript object for
Response.- Author:
- Ahmed Ashour, Ronald Brill
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, LEGACY_CONST, PERMANENT, READONLY, STRICTLY_READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.htmlunit.corejs.javascript.NativePromiseReturns a promise for the body as ArrayBuffer.org.htmlunit.corejs.javascript.NativePromiseblob()Returns a promise for the body as Blob.org.htmlunit.corejs.javascript.NativePromisebytes()Returns a promise for the body as Uint8Array.static Responseerror(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Returns a new network error response.org.htmlunit.corejs.javascript.NativePromiseformData()Returns a promise for the body as FormData.getBody()Returns the body asReadableStream.Returns the headers.intReturns the status.Returns the status text.getType()Returns the type.getUrl()Returns the url.booleanReturns whether the body was used.booleanisOk()Returns whether the status is in the range 200-299.booleanReturns whether the response is the result of a redirect.jsClone()Returns a copy of this response.static ResponsejsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr) JavaScript constructor.org.htmlunit.corejs.javascript.NativePromisejson()Returns a promise for the body parsed as JSON.static ResponsejsonStatic(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Returns a response with the JSON serialization of the given data as body.static Responseredirect(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Returns a redirect response.org.htmlunit.corejs.javascript.NativePromisetext()Returns a promise for the body as text.Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, createDOMException, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getIds, getIndexedPropertyCount, getOwnPropertyDescriptor, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, getWithPreemption, has, hasInstance, isIndexedPropertyWritable, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
Response
public Response()Default constructor.
-
-
Method Details
-
jsConstructor
public static Response jsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr) JavaScript constructor.- Parameters:
cx- the current contextscope- the scopeargs- the arguments (the optional body and the optional init)ctorObj- the function objectinNewExpr- whether invoked vianew- Returns:
- the new
Responseinstance - See Also:
-
error
public static Response error(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Returns a new network error response.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the argumentsfunObj- the function- Returns:
- the error response
-
redirect
public static Response redirect(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Returns a redirect response.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the arguments (the url and the optional status)funObj- the function- Returns:
- the redirect response
-
jsonStatic
public static Response jsonStatic(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Returns a response with the JSON serialization of the given data as body.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the arguments (the data and the optional init)funObj- the function- Returns:
- the response
-
jsClone
Returns a copy of this response.- Returns:
- the copy
-
getType
Returns the type.- Returns:
- the type
-
getUrl
Returns the url.- Returns:
- the url
-
isRedirected
public boolean isRedirected()Returns whether the response is the result of a redirect.- Returns:
- whether the response is the result of a redirect
-
getStatus
public int getStatus()Returns the status.- Returns:
- the status
-
isOk
public boolean isOk()Returns whether the status is in the range 200-299.- Returns:
- whether the status is in the range 200-299
-
getStatusText
Returns the status text.- Returns:
- the status text
-
getHeaders
Returns the headers.- Returns:
- the headers
-
getBody
Returns the body asReadableStream.- Returns:
- the stream or
nullif there is no body
-
isBodyUsed
public boolean isBodyUsed()Returns whether the body was used.- Returns:
- whether the body was used
-
text
public org.htmlunit.corejs.javascript.NativePromise text()Returns a promise for the body as text.- Returns:
- the promise
-
json
public org.htmlunit.corejs.javascript.NativePromise json()Returns a promise for the body parsed as JSON.- Returns:
- the promise
-
arrayBuffer
public org.htmlunit.corejs.javascript.NativePromise arrayBuffer()Returns a promise for the body as ArrayBuffer.- Returns:
- the promise
-
bytes
public org.htmlunit.corejs.javascript.NativePromise bytes()Returns a promise for the body as Uint8Array.- Returns:
- the promise
-
blob
public org.htmlunit.corejs.javascript.NativePromise blob()Returns a promise for the body as Blob.- Returns:
- the promise
-
formData
public org.htmlunit.corejs.javascript.NativePromise formData()Returns a promise for the body as FormData.- Returns:
- the promise
-