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.Headers
- 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
Headers.- Author:
- Ahmed Ashour, Ronald Brill
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe guard of a headers object; determines which changes are allowed.static final classES6Iteratorimplementation for the iterators ofHeaders.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 TypeMethodDescriptionstatic voidappend(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) Appends a new value to an existing header, or adds the header if it does not exist.voidappendHeader(String name, String value) Appends a header after normalizing and validating name and value.voiddeleteHeader(String name) Deletes all values of a header.org.htmlunit.corejs.javascript.ES6Iteratorentries()Returns an iterator over all name/value pairs (sorted, combined; the names in lower case).voidCalls the callback for every header (sorted, combined; the names in lower case).getGuard()Returns the guard.Returns the combined values of a header.Returns the header list (the names as given).org.htmlunit.corejs.javascript.ScriptableReturns the values of all Set-Cookie headers.static booleanisForbiddenRequestHeader(String name, String value, BrowserVersion browserVersion) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns whether the header is a forbidden request header; used byfetch()and byXMLHttpRequest.static HeadersjsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr) JavaScript constructor.static voidjsDelete(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) Deletes a header.static StringjsGet(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 the combined values of a header.static booleanjsHas(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 whether a header exists.static voidjsSet(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) Sets the value of a header (replaces all existing values), or adds the header if it does not exist.org.htmlunit.corejs.javascript.ES6Iteratorkeys()Returns an iterator over all names (sorted, in lower case).voidsetGuard(Headers.Guard guard) Sets the guard.voidSets a header after normalizing and validating name and value.org.htmlunit.corejs.javascript.ES6Iteratorvalues()Returns an iterator over all values (sorted by the names, combined).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
-
Headers
public Headers()Default constructor.
-
-
Method Details
-
jsConstructor
public static Headers 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 initial headers: aHeadersobject, a sequence of name/value pairs or a record)ctorObj- the function objectinNewExpr- whether invoked vianew- Returns:
- the new
Headersinstance
-
append
public static void append(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) Appends a new value to an existing header, or adds the header if it does not exist.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the arguments (name and value)funObj- the function
-
jsSet
public static void jsSet(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) Sets the value of a header (replaces all existing values), or adds the header if it does not exist.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the arguments (name and value)funObj- the function
-
jsDelete
public static void jsDelete(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) Deletes a header.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the arguments (name)funObj- the function
-
jsGet
public static String jsGet(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 the combined values of a header.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the arguments (name)funObj- the function- Returns:
- the values separated by ', ' or
nullif the header does not exist
-
jsHas
public static boolean jsHas(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 whether a header exists.- Parameters:
cx- the current contextscope- the scopethisObj- this objectargs- the arguments (name)funObj- the function- Returns:
- whether the header exists
-
getSetCookie
public org.htmlunit.corejs.javascript.Scriptable getSetCookie()Returns the values of all Set-Cookie headers.- Returns:
- the values
-
forEach
Calls the callback for every header (sorted, combined; the names in lower case).- Parameters:
callback- the function to call with the value, the name and this objectthisArg- the value to use asthisfor the callback
-
entries
public org.htmlunit.corejs.javascript.ES6Iterator entries()Returns an iterator over all name/value pairs (sorted, combined; the names in lower case).- Returns:
- the iterator
-
keys
public org.htmlunit.corejs.javascript.ES6Iterator keys()Returns an iterator over all names (sorted, in lower case).- Returns:
- the iterator
-
values
public org.htmlunit.corejs.javascript.ES6Iterator values()Returns an iterator over all values (sorted by the names, combined).- Returns:
- the iterator
-
appendHeader
Appends a header after normalizing and validating name and value.- Parameters:
name- the namevalue- the value- See Also:
-
setHeader
Sets a header after normalizing and validating name and value.- Parameters:
name- the namevalue- the value- See Also:
-
deleteHeader
Deletes all values of a header.- Parameters:
name- the name
-
getHeader
Returns the combined values of a header.- Parameters:
name- the name- Returns:
- the values separated by ', ' or
nullif the header does not exist
-
getHeaderList
Returns the header list (the names as given).- Returns:
- the header list
-
getGuard
Returns the guard.- Returns:
- the guard
-
setGuard
Sets the guard.- Parameters:
guard- the guard
-
isForbiddenRequestHeader
public static boolean isForbiddenRequestHeader(String name, String value, BrowserVersion browserVersion) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns whether the header is a forbidden request header; used byfetch()and byXMLHttpRequest.Forbidden are the names of the list of the Fetch standard, the names starting with 'proxy-' or 'sec-' and the method override headers (X-HTTP-Method, X-HTTP-Method-Override, X-Method-Override) if one of the values is a forbidden method (CONNECT, TRACE, TRACK).
Like Chrome/Edge, the User-Agent header is forbidden also (featureJS_REQUEST_HEADER_USER_AGENT_FORBIDDEN).- Parameters:
name- the namevalue- the valuebrowserVersion- the browser version- Returns:
- whether the header is a forbidden request header
- See Also:
-