Class ScriptHeaders
- All Implemented Interfaces:
Iterable<String>,org.microproxy.thirdparty.starlark.eval.StarlarkIndexable,org.microproxy.thirdparty.starlark.eval.StarlarkIterable<String>,org.microproxy.thirdparty.starlark.eval.StarlarkMembershipTestable,org.microproxy.thirdparty.starlark.eval.StarlarkSetIndexable,org.microproxy.thirdparty.starlark.eval.StarlarkValue
h[name] is the first value (an error if absent), h[name] =
v replaces all values, name in h tests presence and iterating yields the distinct names.
A frame's header block includes its pseudo-headers (:method, :status, ...).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.microproxy.thirdparty.starlark.eval.StarlarkSetIndexable
org.microproxy.thirdparty.starlark.eval.StarlarkSetIndexable.Threaded -
Method Summary
Modifier and TypeMethodDescriptionvoidAppends values to a header without removing existing values.booleancontainsKey(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics, Object key) Returns whether the key is in the object.Returns the first value of a header, with a caller-supplied fallback.org.microproxy.thirdparty.starlark.eval.StarlarkList<String> Returns every value of a header.static org.microproxy.thirdparty.starlark.syntax.TypeConstructorTypes the builtins that return this class (seeScriptType).Returns the value associated with the given key.org.microproxy.thirdparty.starlark.syntax.StarlarkTypegetStarlarkType(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Returns the type of this Starlark value, or null if no information is provided.booleanReports whether the value is deeply immutable.org.microproxy.thirdparty.starlark.eval.StarlarkList<org.microproxy.thirdparty.starlark.eval.Tuple> items()Returns each header value with its name in header order.iterator()org.microproxy.thirdparty.starlark.eval.StarlarkList<String> keys()Returns the distinct header names.booleanRemoves all values of a header.voidrepr(org.microproxy.thirdparty.starlark.eval.Printer printer, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Prints an official representation of object x.voidReplaces all values of a header.voidsetIndex(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics, Object key, Object value) Updates an object as if by the Starlark statementobject[key] = value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.microproxy.thirdparty.starlark.eval.StarlarkValue
checkHashable, debugPrint, isAcyclic, str, truth
-
Method Details
-
getAssociatedTypeConstructor
public static org.microproxy.thirdparty.starlark.syntax.TypeConstructor getAssociatedTypeConstructor()Types the builtins that return this class (seeScriptType).- Returns:
- the Starlark type constructor for HTTP headers
-
getStarlarkType
public org.microproxy.thirdparty.starlark.syntax.StarlarkType getStarlarkType(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Description copied from interface:org.microproxy.thirdparty.starlark.eval.StarlarkValueReturns the type of this Starlark value, or null if no information is provided.This method should not be called directly in client code. The canonical way to obtain the type of a value is
Starlark.getStarlarkType(java.lang.Object, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics), which injects information obtained in other ways (e.g. from annotations).Overrides of this method should not return null: if this method is overridden, it indicates to the machinery processing
StarlarkBuiltinannotations that the annotated class doesn't need an auto-generatedStarlarkTypeimplementation. Therefore, a null return in an override will causeStarlark.getStarlarkType(java.lang.Object, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics)to fall back to reporting the type asAny.- Specified by:
getStarlarkTypein interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkValue- Parameters:
semantics- the interpreter settings used to determine the type- Returns:
- the type of this value, or null when no type information is provided
-
getIndex
public Object getIndex(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics, Object key) throws org.microproxy.thirdparty.starlark.eval.EvalException Description copied from interface:org.microproxy.thirdparty.starlark.eval.StarlarkIndexableReturns the value associated with the given key.- Specified by:
getIndexin interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkIndexable- Parameters:
semantics- the interpreter settings used for indexed accesskey- the index or mapping key to look up- Returns:
- the associated Starlark value
- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- if the key is invalid or has no associated value
-
containsKey
public boolean containsKey(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics, Object key) throws org.microproxy.thirdparty.starlark.eval.EvalException Description copied from interface:org.microproxy.thirdparty.starlark.eval.StarlarkMembershipTestableReturns whether the key is in the object.- Specified by:
containsKeyin interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkMembershipTestable- Parameters:
semantics- the interpreter settings used for the membership testkey- the value whose membership is tested- Returns:
- whether the object contains the key
- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- if the key is invalid or membership cannot be evaluated
-
setIndex
public void setIndex(org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics, Object key, Object value) throws org.microproxy.thirdparty.starlark.eval.EvalException Description copied from interface:org.microproxy.thirdparty.starlark.eval.StarlarkSetIndexableUpdates an object as if by the Starlark statementobject[key] = value.- Specified by:
setIndexin interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkSetIndexable- Parameters:
semantics- the interpreter settings used for indexed assignmentkey- the index or mapping key to updatevalue- the new Starlark value to associate with the key- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- if underlying object is immutable.
-
iterator
-
get
Returns the first value of a header, with a caller-supplied fallback.- Parameters:
name- the case-insensitive header namedefaultValue- the result when the header is absent- Returns:
- the first header value, or
defaultValue
-
getAll
Returns every value of a header.- Parameters:
name- the case-insensitive header name- Returns:
- an immutable list of values, empty when absent
-
set
public void set(String name, Object value) throws org.microproxy.thirdparty.starlark.eval.EvalException Replaces all values of a header.- Parameters:
name- the header namevalue- a string or a list or tuple of strings- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- if headers are read-only or the name or values are invalid
-
add
public void add(String name, Object value) throws org.microproxy.thirdparty.starlark.eval.EvalException Appends values to a header without removing existing values.- Parameters:
name- the header namevalue- a string or a list or tuple of strings- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- if headers are read-only or the name or values are invalid
-
remove
Removes all values of a header.- Parameters:
name- the case-insensitive header name- Returns:
- whether any values were removed
- Throws:
org.microproxy.thirdparty.starlark.eval.EvalException- if headers are read-only
-
keys
Returns the distinct header names.- Returns:
- an immutable list of header names
-
items
public org.microproxy.thirdparty.starlark.eval.StarlarkList<org.microproxy.thirdparty.starlark.eval.Tuple> items()Returns each header value with its name in header order.- Returns:
- an immutable list of name/value tuples, including repeated names
-
repr
public void repr(org.microproxy.thirdparty.starlark.eval.Printer printer, org.microproxy.thirdparty.starlark.eval.StarlarkSemantics semantics) Description copied from interface:org.microproxy.thirdparty.starlark.eval.StarlarkValuePrints an official representation of object x.Convention is that the string should be parseable back to the value x. If this isn't feasible then it should be a short human-readable description enclosed in angled brackets, e.g.
"<foo object>".- Specified by:
reprin interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkValue- Parameters:
printer- a printer to be used for formatting nested values.semantics- the interpreter settings used to format nested values
-
isImmutable
public boolean isImmutable()Description copied from interface:org.microproxy.thirdparty.starlark.eval.StarlarkValueReports whether the value is deeply immutable.- Specified by:
isImmutablein interfaceorg.microproxy.thirdparty.starlark.eval.StarlarkValue- Returns:
- whether this value and all values reachable from it are immutable
-