Class ResponseHeaderFields

All Implemented Interfaces:
Serializable, Cloneable, Map<String,List<String>>, HeaderFields<ResponseCookie,ResponseHeaderFields>, HttpFields<ResponseHeaderFields>

The ResponseHeaderFields reflect the structure of a HTTP header and may be used to represent a HTTP header.
See Also:
  • Constructor Details

    • ResponseHeaderFields

      public ResponseHeaderFields()
  • Method Details

    • addCookie

      public ResponseCookie addCookie(String aHttpCookie)
      Adds an individual server-side cookie to be sent to the client to this ResponseHeaderFields instance. The server-side cookies are retrieved from the HeaderField.SET_COOKIE Header-Field. WITH THE METHOD HeaderFields.getAllCookies() and HeaderFields.getCookies(String) as well as HeaderFields.getFirstCookie(String) ONLY THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED (E.G. COOKIES RESIDING IN THE HEADER FIELD HeaderField.COOKIE). COOKIES SET VIA HeaderFields.addCookie(String, String) OR HeaderFields.withAddCookie(String, String) CANNOT BE RETRIEVED, AS THE COOKIES BEING SET SERVER-SIDE ARE PUT IN THE HeaderField.SET_COOKIE Header-Field.
      Specified by:
      addCookie in interface HeaderFields<ResponseCookie,ResponseHeaderFields>
      Parameters:
      aHttpCookie - The HTTP-Cookie String to be paresd as a cookie.
      Returns:
      The resulting cookie builder being added which can be modified affecting(!) this ResponseHeaderFields instance!
    • witAddCookie

      public ResponseHeaderFields witAddCookie(String aHttpCookie)
      Parameters:
      aHttpCookie - The cookie to be added.
      Returns:
      The implementing instance as of the builder pattern.
    • withAddCookie

      public ResponseHeaderFields withAddCookie(ResponseCookie aCookie)
      Builder method for the HeaderFields.addCookie(Cookie) method. WITH THE METHOD HeaderFields.getAllCookies() and HeaderFields.getCookies(String) as well as HeaderFields.getFirstCookie(String) ONLY THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED (E.G. COOKIES RESIDING IN THE HEADER FIELD HeaderField.COOKIE). COOKIES SET VIA HeaderFields.addCookie(String, String) OR HeaderFields.withAddCookie(String, String) CANNOT BE RETRIEVED, AS THE COOKIES BEING SET SERVER-SIDE ARE PUT IN THE HeaderField.SET_COOKIE Header-Field.
      Specified by:
      withAddCookie in interface HeaderFields<ResponseCookie,ResponseHeaderFields>
      Parameters:
      aCookie - The cookie to be added.
      Returns:
      This ResponseHeaderFields instance to continue building up the Header-Fields.
    • getLocation

      public String getLocation()
      Gets the Location Response-Header-Field HeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. ..."
      Returns:
      The expected (supported) kinds of MediaType and the according parameters (being actually instances of the String type).
      See Also:
      • "https://tools.ietf.org/html/rfc2616#page-135"
    • putLocation

      public String putLocation(String aLocation)
      Sets the Location Response-Header-Field HeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. types ..."
      Parameters:
      aLocation - The according location.
      Returns:
      The replaced element (if any, else null).
      See Also:
      • "https://tools.ietf.org/html/rfc2616#page-135"
    • withLocation

      public ResponseHeaderFields withLocation(String aLocation)
      Sets the Location Response-Header-Field HeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. types ..."
      Parameters:
      aLocation - The according location.
      Returns:
      This object as of the Builder-Pattern.
      See Also:
      • "https://tools.ietf.org/html/rfc2616#page-135"
    • removeLocation

      public String removeLocation()
      Removes the Location Response-Header-Field HeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. types ..."
      Returns:
      The value being removed (or null if none was set).
      See Also:
      • "https://tools.ietf.org/html/rfc2616#page-135"
    • getCookieFieldName

      protected String getCookieFieldName()
      The Header-Field name for the Cookie elements. The Header-Field name differs from the context, e.g. when setting a Cookie server-side or when retrieving a Cookie client-side.
      Specified by:
      getCookieFieldName in class AbstractHeaderFields<ResponseCookie,ResponseHeaderFields>
      Returns:
      The Header-Field where the Cookie elements are stored.
    • createCookie

      protected ResponseCookie createCookie(String aCookieName, String aValue)
      Creates a plain Cookie with the given name and value.
      Specified by:
      createCookie in class AbstractHeaderFields<ResponseCookie,ResponseHeaderFields>
      Parameters:
      aCookieName - The name of the Cookie.
      aValue - The value for the Cookie
      Returns:
      The Cookie with the given name and value.
    • createCookie

      protected ResponseCookie createCookie(String aHttpCookie)
      Creates a Cookie from the given HTTP cookie String as retrieved from the according Header-Field.
      Specified by:
      createCookie in class AbstractHeaderFields<ResponseCookie,ResponseHeaderFields>
      Parameters:
      aHttpCookie - The text of the Header-Field for the cookie to be created.
      Returns:
      The Cookie with the given cookie properties.