Class HttpObject

java.lang.Object
java.net.http.HttpRequest
org.nanonative.nano.services.http.model.HttpObject

public class HttpObject extends HttpRequest
Represents an HTTP request and response object within a server handling context. This class provides methods to manage HTTP details such as headers, body, and status code, as well as utilities to check request types and content in a fluent and chaining API.
  • Field Details

    • method

      protected HttpMethod method
    • path

      protected String path
    • body

      protected byte[] body
    • headers

      protected berlin.yuna.typemap.model.TypeMap headers
    • queryParams

      protected berlin.yuna.typemap.model.TypeMap queryParams
    • pathParams

      protected berlin.yuna.typemap.model.TypeMap pathParams
    • statusCode

      protected int statusCode
    • timeoutMs

      protected Long timeoutMs
    • exchange

      protected final HttpExchange exchange
    • HTTP_EXCEPTION_HEADER

      public static final String HTTP_EXCEPTION_HEADER
      See Also:
    • HTTP_DATE_FORMATTER

      public static final DateTimeFormatter HTTP_DATE_FORMATTER
    • USER_AGENT_BROWSERS

      public static final String[] USER_AGENT_BROWSERS
    • USER_AGENT_MOBILE

      public static final String[] USER_AGENT_MOBILE
    • CONTEXT_HTTP_CLIENT_KEY

      public static final String CONTEXT_HTTP_CLIENT_KEY
      See Also:
    • JAVA_MANAGED_HEADERS

      public static final List<String> JAVA_MANAGED_HEADERS
  • Constructor Details

    • HttpObject

      public HttpObject(HttpExchange exchange)
      Constructs a new HttpObject from a specified HttpExchange. Initializes headers, method, and path. The HttpExchange is lazy loaded. Methods like body() will trigger the loading of the request body.
      Parameters:
      exchange - the HttpExchange containing the request details.
    • HttpObject

      public HttpObject()
      Constructs a HttpObject.
  • Method Details

    • methodType

      public HttpMethod methodType()
      Returns the current HTTP method of this object.
      Returns:
      the current HttpMethod.
    • methodType

      public HttpObject methodType(String method)
      Sets the HTTP method for this object.
      Parameters:
      method - the HTTP method as a string. null if method is not one of HttpMethod.
      Returns:
      this HttpObject for method chaining.
    • methodType

      public HttpObject methodType(HttpMethod method)
      Sets the HTTP method for this object.
      Parameters:
      method - the HTTP method as an enum HttpMethod.
      Returns:
      this HttpObject for method chaining.
    • contentType

      public ContentType contentType()
      Retrieves the first content types specified in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      the primary ContentType of the request, or null if no content type is set.
    • contentTypes

      public List<ContentType> contentTypes()
      Retrieves a list of all content types specified in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      a list of ContentType objects representing each content type specified.
    • contentType

      public HttpObject contentType(String... contentType)
      Sets the HttpHeaders.CONTENT_TYPE header without specifying a Charset.
      Parameters:
      contentType - array of content type strings to be set in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      this HttpObject to allow method chaining.
    • contentType

      public HttpObject contentType(ContentType... contentType)
      Sets the HttpHeaders.CONTENT_TYPE header without specifying a Charset.
      Parameters:
      contentType - array of content type strings to be set in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      this HttpObject to allow method chaining.
    • contentType

      public HttpObject contentType(Charset charset, String... contentType)
      Sets the HttpHeaders.CONTENT_TYPE header with specifying a Charset.
      Parameters:
      charset - the Charset to set for body encoding.
      contentType - array of content type strings to be set in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      this HttpObject to allow method chaining.
    • contentType

      public HttpObject contentType(Charset charset, ContentType... contentType)
      Sets the HttpHeaders.CONTENT_TYPE header with specifying a Charset.
      Parameters:
      charset - the Charset to set for body encoding.
      contentType - array of content type strings to be set in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      this HttpObject to allow method chaining.
    • accept

      public ContentType accept()
    • accepts

      public List<ContentType> accepts()
    • accept

      public HttpObject accept(String... contentType)
    • accept

      public HttpObject accept(ContentType... contentType)
    • hasAccept

      public boolean hasAccept(String... contentTypes)
    • hasAccept

      public boolean hasAccept(ContentType... contentTypes)
    • acceptEncoding

      public String acceptEncoding()
    • acceptEncodings

      public List<String> acceptEncodings()
    • hasAcceptEncoding

      public boolean hasAcceptEncoding(String... encodings)
    • contentEncoding

      public String contentEncoding()
    • contentEncodings

      public List<String> contentEncodings()
    • hasContentEncoding

      public boolean hasContentEncoding(String... encodings)
    • acceptLanguage

      public Locale acceptLanguage()
    • acceptLanguages

      public List<Locale> acceptLanguages()
    • acceptLanguages

      public HttpObject acceptLanguages(Locale... locales)
      Sets the accepted languages based on a list where the order indicates priority. The first language in the list has the highest priority, automatically assigning descending priorities.
      Parameters:
      locales - Ordered array of Locale representing the preferred languages, from most to least preferred.
      Returns:
      this HttpObject to allow method chaining.
    • path

      public String path()
      Retrieves the current path of the HttpObject without last '/'.
      Returns:
      the request path.
    • path

      public HttpObject path(String path)
      Sets the path for this HttpObject. This method also parses and sets the query parameters if they are included in the path.
      Parameters:
      path - the path to set, which may include query parameters.
      Returns:
      this HttpObject to allow method chaining.
    • bodyAsString

      public String bodyAsString()
      Returns a string representation of the body(), decoded using the Charset from encoding() specified in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      the body as a string.
    • bodyAsJson

      public berlin.yuna.typemap.model.TypeInfo<?> bodyAsJson()
      Returns a string representation of the body(), decoded using the Charset from encoding() specified in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      the body as a json.
    • bodyAsXml

      public berlin.yuna.typemap.model.TypeInfo<?> bodyAsXml()
      Returns a string representation of the body(), decoded using the Charset from encoding() specified in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      the body as a xml.
    • body

      public byte[] body()
      Returns a string representation of the body, decoded using the Charset from encoding() specified in the HttpHeaders.CONTENT_TYPE header.
      Returns:
      the body as a xml.
    • bodyT

      public HttpObject bodyT(berlin.yuna.typemap.model.TypeInfo<?> body)
      Sets the body() from a TypeInfo object, encoding it into JSON format using the Charset from encoding().
      Parameters:
      body - the TypeInfo representing the body to be set.
      Returns:
      this HttpObject to allow method chaining.
    • body

      public HttpObject body(Collection<?> body)
      Sets the body() from a Collection object, encoding it into JSON format using the Charset from encoding().
      Parameters:
      body - the Collection representing the body to be set.
      Returns:
      this HttpObject to allow method chaining.
    • body

      public HttpObject body(Map<?,?> body)
      Sets the body() from a Map object, encoding it into JSON format using the Charset from encoding().
      Parameters:
      body - the Map representing the body to be set.
      Returns:
      this HttpObject to allow method chaining.
    • body

      public HttpObject body(String body)
      Sets the body() from a TypeInfo object, encoding it into bytes using the Charset from encoding().
      Parameters:
      body - the String representing the body to be set.
      Returns:
      this HttpObject to allow method chaining.
    • body

      public HttpObject body(byte[] body)
      Sets the body() from a TypeInfo object.
      Parameters:
      body - the String representing the body to be set.
      Returns:
      this HttpObject to allow method chaining.
    • queryParams

      public berlin.yuna.typemap.model.TypeMap queryParams()
      Retrieves all query parameters from the current HttpObject.
      Returns:
      a TypeMap containing all the query parameters.
    • containsQueryParam

      public boolean containsQueryParam(String key)
      Checks if a specific query parameter exists in the HttpObject.
      Parameters:
      key - the query parameter key to check.
      Returns:
      true if the parameter exists, false otherwise.
    • queryParam

      public String queryParam(String key)
      Retrieves the value of a specified query parameter.
      Parameters:
      key - the key of the query parameter to retrieve.
      Returns:
      the value of the parameter as a String, or null if the parameter does not exist.
    • pathMatch

      public boolean pathMatch(String expression)

      Checks if the current path() matches a specified expression. The expression may include:

      • Path variables enclosed in curly braces ({}), e.g., /users/{userId}.
      • Asterisks (*) to match any single path segment, e.g., /users/*/profile
      • Double asterisks (**) to match any number of path segments, e.g., /users/**..

      Matching rules:

      • Exact match: Each part of the path must match the corresponding part of the expression.
      • Single asterisk (*): Matches any single path segment.
      • Double asterisk (**): Matches zero or more path segments.
      • Path variables: Captures the value of the segment and stores it in pathParams().
      Parameters:
      expression - the path expression to match against the current path.
      Returns:
      true if the current path matches the expression, false otherwise.
    • pathParams

      public berlin.yuna.typemap.model.TypeMap pathParams()
      Retrieves a map of path parameters extracted from the URL.
      Returns:
      a TypeMap of path parameters.
    • pathParam

      public String pathParam(String key)
      Retrieves the value of a specified path parameter.
      Parameters:
      key - the key of the path parameter.
      Returns:
      the value of the path parameter, or null if it does not exist.
    • header

      public String header(String key)
      Retrieves the value of a specified header.
      Parameters:
      key - the key of the header to retrieve.
      Returns:
      the value of the header, or null if the header is not found or key is null.
    • containsHeader

      public boolean containsHeader(String key)
      Checks if a specified header exists in the HttpObject.
      Parameters:
      key - the key of the header to check.
      Returns:
      true if the header exists, false otherwise.
    • userAgent

      public String userAgent()
      Retrieves the HttpHeaders.USER_AGENT header from the HttpObject.
      Returns:
      the user agent string, or null if not set.
    • userAgent

      public HttpObject userAgent(String userAgent)
      Sets the HttpHeaders.USER_AGENT header for the HttpObject.
      Parameters:
      userAgent - the user agent string to set.
      Returns:
      this HttpObject to allow method chaining.
    • authToken

      public String authToken()
      Parses and returns any authentication token found in the HttpHeaders.AUTHORIZATION header. Supports both 'Bearer' and 'Basic' authentication schemes.
      Returns:
      token from the authTokens() or null if no HttpHeaders.AUTHORIZATION header is present or the token cannot be parsed.
    • authToken

      public String authToken(int index)
      Parses and returns any authentication token found in the HttpHeaders.AUTHORIZATION header. Supports both 'Bearer' and 'Basic' authentication schemes.
      Returns:
      token from the authTokens() or null if no HttpHeaders.AUTHORIZATION header is present or the token cannot be parsed.
    • authTokens

      public String[] authTokens()
      Parses and returns any authentication token found in the HttpHeaders.AUTHORIZATION header. Supports both 'Bearer' and 'Basic' authentication schemes.
      Returns:
      an array of strings, where the first element is the token or credentials, or an empty array if no HttpHeaders.AUTHORIZATION header is present or the token cannot be parsed.
    • exchange

      public HttpExchange exchange()
      Returns the associated HttpExchange for this HttpObject.
      Returns:
      the HttpExchange, or null if not available.
    • statusCode

      public HttpObject statusCode(int statusCode)
      Sets the HTTP status code for the HttpObject.
      Parameters:
      statusCode - the HTTP status code to set.
      Returns:
      this HttpObject to allow method chaining.
    • statusCode

      public int statusCode()
      Retrieves the current HTTP status code for the HttpObject.
      Returns:
      the HTTP status code.
    • headerMap

      public berlin.yuna.typemap.model.TypeMap headerMap()
      Returns the HTTP headers map.
      Returns:
      a TypeMap containing the headers.
    • computedHeaders

      public Map<String,List<String>> computedHeaders(boolean isRequest)

      Constructs and returns a map of HTTP headers to be included in an HTTP response. This method ensures that essential headers are set, providing a sensible default for headers like Content-Encoding, Connection, Cache-Control, Accept-Encoding, Content-Type, Content-Length, and Date.

      The method sets defaults for managing caching, connection persistence, and content encoding to optimize performance and compliance with HTTP standards. It also dynamically calculates content length and sets the current date and time in GMT format.

      Returns:
      A map where keys are header names and values are lists of string representing the header values. This structure supports headers having multiple values.

      Header Details: - HttpHeaders.ACCEPT: Default "*\/*". - HttpHeaders.CACHE_CONTROL: Ensures fresh content by specifying "no-cache" and overrides with "max-age=0, private, must-revalidate" for more specific caching rules. - HttpHeaders.ACCEPT_ENCODING: Lists the acceptable encodings the server can handle, defaults to "gzip, deflate". - HttpHeaders.CONTENT_TYPE: Determined by contentTypes() method to set the correct media type of the response. - HttpHeaders.CONTENT_LENGTH: Calculates the length of the response body to inform the client of the size of the response. - HttpHeaders.DATE: Sets the current date and time formatted according to RFC 7231.

    • sizeRequest

      public HttpObject sizeRequest(boolean sizeRequest)
      Sets the HTTP Range header to request only the first byte of the content. This method is typically used to determine the size of the content without downloading it entirely. The server should respond with the Content-Range header which includes the total size of the requested resource.
      Returns:
      this HttpObject to allow method chaining.
    • sizeRequest

      public boolean sizeRequest()
      Checks if the Range header has been set to request only the first byte of the content. This method is used to determine if the current request is a size request, which is typically used to fetch the size of the content without fully downloading it.
      Returns:
      true if the Range header is set to "bytes=0-0", indicating a size request; false otherwise.
    • size

      public long size()

      Calculates the size of the HTTP content. This method first attempts to retrieve the content size from the HTTP headers. It checks the Content-Length header for a direct size declaration. If not present, it tries to extract the size from the Content-Range header, which is used in responses to range requests.

      If neither header is present or they don't contain valid size information, the method falls back to the length of the body, which is loaded into memory.

      Returns:
      the size of the content as a long. If the size cannot be determined from the headers, it returns the length of the body. If the headers are not set or are invalid, and the body is not loaded, it returns -1.
    • headerMap

      public HttpObject headerMap(Headers headers)
      Sets Http headers.
      Parameters:
      headers - the header keys and values.
      Returns:
      this HttpObject for method chaining.
    • headerMap

      public HttpObject headerMap(Map<String,?> headers)
      Sets Http headers.
      Parameters:
      headers - the header keys and values.
      Returns:
      this HttpObject for method chaining.
    • header

      public HttpObject header(String key, Object value)
      Adds or replaces a header in the HTTP headers map.
      Parameters:
      key - the header name.
      value - the header value.
      Returns:
      this HttpObject for method chaining.
    • queryParamsOf

      protected berlin.yuna.typemap.model.TypeMap queryParamsOf(String query)
    • bodyPublisher

      public Optional<HttpRequest.BodyPublisher> bodyPublisher()
      Specified by:
      bodyPublisher in class HttpRequest
    • method

      public String method()
      Specified by:
      method in class HttpRequest
    • timeout

      public Optional<Duration> timeout()
      Specified by:
      timeout in class HttpRequest
    • timeout

      public HttpObject timeout(long timeoutMs)
    • expectContinue

      public boolean expectContinue()
      Specified by:
      expectContinue in class HttpRequest
    • uri

      public URI uri()
      Specified by:
      uri in class HttpRequest
    • version

      public Optional<HttpClient.Version> version()
      Specified by:
      version in class HttpRequest
    • headers

      public HttpHeaders headers()
      Specified by:
      headers in class HttpRequest
    • response

      public HttpObject response()
      Creates and returns a new instance of HttpObject. This method is typically used to prepare a fresh response object in the context of HTTP handling. The new instance is completely independent of the current object, meaning it has no initialized fields from the current context.
      Returns:
      a new, empty HttpObject.
    • corsResponse

      public HttpObject corsResponse()
      Creates and returns a new instance of HttpObject. If CORS handling is requested, it delegates to the CORS response method.
      Returns:
      a new HttpObject, CORS-enabled.
    • response

      public HttpObject response(boolean cors)
      Creates and returns a new instance of HttpObject. If CORS handling is requested, it delegates to the CORS response method.
      Parameters:
      cors - if true, generates a CORS-enabled response.
      Returns:
      a new HttpObject, optionally CORS-enabled.
    • corsResponse

      public HttpObject corsResponse(String origin)
      Creates and returns a new instance of HttpObject with CORS handling. If the origin is not provided, it defaults to "*" (wildcard).
      Parameters:
      origin - comma separated list of whitelisted origins, or null for default.
      Returns:
      a new HttpObject with CORS handling.
    • corsResponse

      public HttpObject corsResponse(String origin, String methods)
      Creates and returns a new instance of HttpObject with CORS handling. Allows defining the origin and allowed methods.
      Parameters:
      origin - comma separated list of whitelisted origins, or null for default.
      methods - the allowed HTTP methods, or null to use the current method.
      Returns:
      a new HttpObject with CORS handling.
    • corsResponse

      public HttpObject corsResponse(String origin, String methods, String headers)
      Creates and returns a new instance of HttpObject with CORS handling. Allows defining the origin, methods, and headers.
      Parameters:
      origin - comma separated list of whitelisted origins, or null for default.
      methods - the allowed HTTP methods, or null to use the current method.
      headers - the allowed HTTP headers, or null to default headers.
      Returns:
      a new HttpObject with CORS handling.
    • corsResponse

      public HttpObject corsResponse(String origin, String methods, String headers, int maxAge)
      Creates and returns a new instance of HttpObject with CORS handling. Allows defining the origin, methods, headers, and max age for caching preflight responses.
      Parameters:
      origin - comma separated list of whitelisted origins, or null for default.
      methods - the allowed HTTP methods, or null to use the current method.
      headers - the allowed HTTP headers, or null to default headers.
      maxAge - the max age for caching preflight responses, or -1 for default (86400 seconds).
      Returns:
      a new HttpObject with CORS handling.
    • corsResponse

      public HttpObject corsResponse(String origin, String methods, String headers, int maxAge, boolean credentials)
      Creates and returns a new instance of HttpObject with CORS handling. Allows defining the origin, methods, headers, max age, and whether to allow credentials.
      Parameters:
      origin - comma separated list of whitelisted origins, or null for default.
      methods - the allowed HTTP methods, or null to use the current method.
      headers - the allowed HTTP headers, or null to default headers.
      maxAge - the max age for caching preflight responses, or -1 for default (86400 seconds).
      credentials - if true, enables Access-Control-Allow-Credentials header.
      Returns:
      a new HttpObject with CORS handling.
    • origin

      public String origin()
      Retrieves the origin from the current request. If the request does not specify an origin, it defaults to "*".
      Returns:
      the origin of the request, or "*" if no origin is specified.
    • origin

      public String origin(String origin, boolean credentials)
      Determines the value for the Access-Control-Allow-Origin header.

      If credentials are allowed, the origin cannot be "*". It prioritizes the provided origin. If no valid origin is provided, it falls back to the ORIGIN or HOST headers from the request. Returns "null" if credentials are used and no origin is found, otherwise returns "*".

      Parameters:
      origin - comma separated list of whitelisted origins, or null for default.
      credentials - if true, prevents using "*" as the origin.
      Returns:
      the appropriate origin, or "null" if credentials are used and no origin is found.
    • origin

      public HttpObject origin(String origin)
      Sets the origin header for the current HttpObject. If the provided origin is null or empty, the origin header is removed.
      Parameters:
      origin - the origin to set in the headers.
      Returns:
      this HttpObject for method chaining.
    • respond

      public Event respond(Event event)
      Sends an HTTP response using the current HttpObject as the response context. This method utilizes the provided Event to carry the response back to the event handler or processor. The HttpObject is attached to the event as its response payload, allowing further processing or handling.
      Parameters:
      event - the event to which this HttpObject should be attached as a response.
      Returns:
      the event after attaching this HttpObject as a response, facilitating chaining and further manipulation.
    • send

      public HttpObject send(Context context)
      Sends an HTTP request using the provided HttpObject. For async processing, use the send(Context, Consumer) method.
      Returns:
      the response as an HttpObject
    • send

      public HttpObject send(Context context, Consumer<HttpObject> callback)
      Sends an HTTP request using the provided HttpObject. If a response listener is provided, it processes the response asynchronously.
      Parameters:
      callback - an optional consumer to process the response asynchronously
      Returns:
      the response as an HttpObject
    • hasFailed

      public boolean hasFailed()
      Checks if the HTTP response headers contain an entry indicating an exception or failure. This is typically used to determine if the HTTP operation encountered any errors that were captured and stored in the headers.
      Returns:
      true if an exception or failure is indicated in the headers, false otherwise.
    • failure

      public Throwable failure()
      Retrieves the failure exception from the HTTP headers, if present. This method directly accesses the headers to pull out a Throwable object which represents the exception that was encountered during the HTTP transaction.
      Returns:
      the Throwable that represents the failure, or null if no failure was recorded.
    • successOrElse

      public HttpObject successOrElse(Consumer<HttpObject> onSuccess, Consumer<HttpObject> onFailure)
    • failure

      public HttpObject failure(int statusCode, Throwable throwable)
      Stores a failure exception within the HTTP headers. RFC 7807 To The Rescue! This method allows an exception to be attached to the HTTP object, potentially for logging purposes or for transmitting error information back to a client or server.
      Parameters:
      throwable - the Throwable exception to store in the headers.
      Returns:
      this HttpObject to allow for method chaining.
    • isFrontendCall

      public boolean isFrontendCall()
      Determines if the HttpObject originates from a standard web browser based on the HttpHeaders.USER_AGENT header. See USER_AGENT_BROWSERS for the list of browser identifiers.
      Returns:
      true if the HttpHeaders.USER_AGENT header contains identifiers typical of desktop browsers, otherwise false.
    • isMobileCall

      public boolean isMobileCall()
      Determines if the HttpObject originates from a mobile device based on the HttpHeaders.USER_AGENT header. See USER_AGENT_MOBILE for the list of mobile identifiers.
      Returns:
      true if the HttpHeaders.USER_AGENT header contains identifiers typical of mobile devices, otherwise false.
    • host

      public String host()
      Retrieves the host name from the HttpExchange if available, otherwise extracts it from the HttpHeaders.HOST header.
      Returns:
      the host name as a string, or null if it cannot be determined.
    • port

      public int port()
      Retrieves the host port from the HttpExchange if available, otherwise extracts it from the HttpHeaders.HOST header.
      Returns:
      the port number as an integer, or -1 if it cannot be determined.
    • address

      public InetAddress address()
      Retrieves the InetAddress from the HttpExchange.
      Returns:
      an InetAddress representing the remote address, or null if it is not available.
    • protocol

      public String protocol()
      Retrieves the protocol used in the HttpExchange.
      Returns:
      the protocol as a string, or null if the exchange is not available.
    • encoding

      public Charset encoding()
      Retrieves the character set encoding from the HttpHeaders.CONTENT_TYPE header.
      Returns:
      a Charset object representing the encoding specified in the HttpHeaders.CONTENT_TYPE header, or the Charset.defaultCharset() if none is specified.
    • hasContentType

      public boolean hasContentType(String... contentTypes)
    • hasContentType

      public boolean hasContentType(ContentType... contentTypes)
    • hasContentType

      public boolean hasContentType(ContentType contentType)
    • isMethodGet

      public boolean isMethodGet()
    • isMethodPost

      public boolean isMethodPost()
    • isMethodPut

      public boolean isMethodPut()
    • isMethodHead

      public boolean isMethodHead()
    • isMethodPatch

      public boolean isMethodPatch()
    • isMethodDelete

      public boolean isMethodDelete()
    • isMethodOptions

      public boolean isMethodOptions()
    • isMethodTrace

      public boolean isMethodTrace()
    • hasContentTypeJson

      public boolean hasContentTypeJson()
    • hasContentTypeXml

      public boolean hasContentTypeXml()
    • hasContentTypeXmlSoap

      public boolean hasContentTypeXmlSoap()
    • hasContentTypeOctetStream

      public boolean hasContentTypeOctetStream()
    • hasContentTypePdf

      public boolean hasContentTypePdf()
    • hasContentTypeFormUrlEncoded

      public boolean hasContentTypeFormUrlEncoded()
    • hasContentTypeMultiPartFormData

      public boolean hasContentTypeMultiPartFormData()
    • hasContentTypePlainText

      public boolean hasContentTypePlainText()
    • hasContentTypeHtml

      public boolean hasContentTypeHtml()
    • hasContentTypeJpeg

      public boolean hasContentTypeJpeg()
    • hasContentTypePng

      public boolean hasContentTypePng()
    • hasContentTypeGif

      public boolean hasContentTypeGif()
    • hasContentTypeMpeg

      public boolean hasContentTypeMpeg()
    • hasContentTypeMp4

      public boolean hasContentTypeMp4()
    • hasAcceptJson

      public boolean hasAcceptJson()
    • hasAcceptXml

      public boolean hasAcceptXml()
    • hasAcceptXmlSoap

      public boolean hasAcceptXmlSoap()
    • hasAcceptOctetStream

      public boolean hasAcceptOctetStream()
    • hasAcceptPdf

      public boolean hasAcceptPdf()
    • hasAcceptFormUrlEncoded

      public boolean hasAcceptFormUrlEncoded()
    • hasAcceptMultiPartFormData

      public boolean hasAcceptMultiPartFormData()
    • hasAcceptPlainText

      public boolean hasAcceptPlainText()
    • hasAcceptHtml

      public boolean hasAcceptHtml()
    • hasAcceptJpeg

      public boolean hasAcceptJpeg()
    • hasAcceptPng

      public boolean hasAcceptPng()
    • hasAcceptGif

      public boolean hasAcceptGif()
    • hasAcceptMpeg

      public boolean hasAcceptMpeg()
    • hasAcceptMp4

      public boolean hasAcceptMp4()
    • is1xxInformational

      public boolean is1xxInformational()
    • is2xxSuccessful

      public boolean is2xxSuccessful()
    • is3xxRedirection

      public boolean is3xxRedirection()
    • is4xxClientError

      public boolean is4xxClientError()
    • is5xxServerError

      public boolean is5xxServerError()
    • fromExchange

      public <T> T fromExchange(Function<HttpExchange,T> mapper)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • guessContentType

      public static ContentType guessContentType(HttpObject response, byte[] body)
    • splitHeaderValue

      public static <R> List<R> splitHeaderValue(Collection<String> value, Function<String,R> mapper)
    • isMethod

      public static boolean isMethod(HttpObject request, HttpMethod method)
    • convertHeaders

      public static berlin.yuna.typemap.model.TypeMap convertHeaders(Map<String,?> headers)
      Converts a map of simple header values to a TypeMap of headers.
      Parameters:
      headers - a map containing header names and values.
      Returns:
      a TypeMap representing the headers.
    • removeLast

      public static String removeLast(String input, String removable)
    • isDeflateCompressed

      public boolean isDeflateCompressed(byte[] body)
    • isZipCompressed

      public boolean isZipCompressed(byte[] body)