Module org.htmlunit

Class Response

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

public class Response extends HtmlUnitScriptable
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_CONST

    Fields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    isSealed

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.htmlunit.corejs.javascript.NativePromise
    Returns a promise for the body as ArrayBuffer.
    org.htmlunit.corejs.javascript.NativePromise
    Returns a promise for the body as Blob.
    org.htmlunit.corejs.javascript.NativePromise
    Returns a promise for the body as Uint8Array.
    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.
    org.htmlunit.corejs.javascript.NativePromise
    Returns a promise for the body as FormData.
    Returns the body as ReadableStream.
    Returns the headers.
    int
    Returns the status.
    Returns the status text.
    Returns the type.
    Returns the url.
    boolean
    Returns whether the body was used.
    boolean
    Returns whether the status is in the range 200-299.
    boolean
    Returns whether the response is the result of a redirect.
    Returns a copy of this response.
    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.
    org.htmlunit.corejs.javascript.NativePromise
    Returns a promise for the body parsed as JSON.
    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.
    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.
    org.htmlunit.corejs.javascript.NativePromise
    Returns a promise for the body as text.

    Methods 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, size

    Methods 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, writeMaps

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.htmlunit.corejs.javascript.Scriptable

    get, getIds, has, has

    Methods 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 context
      scope - the scope
      args - the arguments (the optional body and the optional init)
      ctorObj - the function object
      inNewExpr - whether invoked via new
      Returns:
      the new Response instance
      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 context
      scope - the scope
      thisObj - this object
      args - the arguments
      funObj - 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 context
      scope - the scope
      thisObj - this object
      args - 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 context
      scope - the scope
      thisObj - this object
      args - the arguments (the data and the optional init)
      funObj - the function
      Returns:
      the response
    • jsClone

      public Response jsClone()
      Returns a copy of this response.
      Returns:
      the copy
    • getType

      public String getType()
      Returns the type.
      Returns:
      the type
    • getUrl

      public String 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

      public String getStatusText()
      Returns the status text.
      Returns:
      the status text
    • getHeaders

      public Headers getHeaders()
      Returns the headers.
      Returns:
      the headers
    • getBody

      public ReadableStream getBody()
      Returns the body as ReadableStream.
      Returns:
      the stream or null if 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