@haxall/haxall
    Preparing search index...

    Class Cookie

    Cookie models an HTTP cookie used to pass data between the server and user agent as defined by RFC 6265.

    See WebReq.cookies and WebRes.cookies.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Parameters

      • it: string

      Returns void

    • Parameters

      • it: boolean

      Returns void

    • Parameters

      Returns void

    • Parameters

      • it: string

      Returns void

    • Parameters

      • it: string

      Returns void

    • Parameters

      • it: string

      Returns void

    • Parameters

      • it: boolean

      Returns void

    • Parameters

      • it: string

      Returns void

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Specifies the domain for which the cookie is valid. An explicit domain must always start with a dot. If null (the default) then the cookie only applies to the server which set it.

      Returns string

    • Compare this object to the specified for equality. This method may be accessed via the == and != shortcut operators. If not overridden the default implementation compares for reference equality using the === operator. If this method is overridden, then hash() must also be overridden such that any two objects which return true for equals() must return the same value for hash(). This method must accept null and return false.

      Parameters

      Returns boolean

    • Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.

      Returns number

    • If true, then the cookie is not available to JavaScript. Defaults to true.

      Returns boolean

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Defines the lifetime of the cookie, after the the max-age elapses the client should discard the cookie. The duration is floored to seconds (fractional seconds are truncated). If maxAge is null (the default) then the cookie persists until the client is shutdown. If zero is specified, the cookie is discarded immediately. Note that many browsers still don't recognize max-age, so setting max-age also always includes an expires attribute.

      Returns Duration

    • Name of the cookie.

      Returns string

    • Specifies the subset of URLs to which the cookie applies. If set to "/" (the default), then the cookie applies to all paths. If the path is null, it as assumed to be the same path as the document being described by the header which contains the cookie.

      Returns string

    • If this value is non-null, then we add the SameSite attribute to the cookie. Valid values are

      • lax
      • strict By default we set the attribute to strict

      Returns string

    • If true, then the client only sends this cookie using a secure protocol such as HTTPS. Defaults to false.

      Returns boolean

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Return the cookie formatted as an Set-Cookie HTTP header.

      Returns string

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • Value string of the cookie.

      Returns string

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • Parse a HTTP cookie header name/value pair. The parsing of the name-value pair is done according to the algorithm outlined in § 5.2 of the RFC.

      Throw ParseErr or return null if not formatted correctly.

      Parameters

      • s: string
      • Optionalchecked: boolean
      • ...args: unknown[]

      Returns Cookie

    • Construct with name and value. The name must be a valid HTTP token and must not start with "$" (see WebUtil.isToken). The value string must be an ASCII string within the inclusive range of 0x20 and 0x7e (see WebUtil.toQuotedStr) with the exception of the semicolon.

      Fantom cookies will use quoted string values, however some browsers such as IE won't parse a quoted string with semicolons correctly, so we make semicolons illegal. If you have a value which might include non-ASCII characters or semicolons, then consider encoding using something like Base64:

      // write response
      res.cookies.add(Cookie("baz", val.toBuf.toBase64))

      // read from request
      val := Buf.fromBase64(req.cookies.get("baz", "")).readAllStr

      Parameters

      • name: string
      • val: string
      • Optionalf: (arg0: Cookie) => void
      • ...args: unknown[]

      Returns Cookie