Class Request

  • All Implemented Interfaces:
    Recyclable

    public class Request
    extends java.lang.Object
    implements Recyclable
    Request

    If a log record was generated as a result of a http request, the http interface can be used to collect this information.

    • Constructor Detail

      • Request

        public Request()
    • Method Detail

      • getBody

        @Nullable
        public java.lang.Object getBody()
        Data should only contain the request body (not the query string). It can either be a dictionary (for standard HTTP requests) or a raw request body.
      • getRawBody

        @Nullable
        public java.lang.String getRawBody()
      • setRawBody

        public void setRawBody​(java.lang.String rawBody)
        Sets the body as a raw string and removes any previously set postParams or bodyBuffer.
        Parameters:
        rawBody - the body as a raw string
      • redactBody

        public void redactBody()
      • addFormUrlEncodedParameter

        public Request addFormUrlEncodedParameter​(java.lang.String key,
                                                  java.lang.String value)
      • addFormUrlEncodedParameters

        public Request addFormUrlEncodedParameters​(java.lang.String key,
                                                   java.lang.String[] values)
      • withBodyBuffer

        public java.nio.CharBuffer withBodyBuffer()
        Gets a pooled CharBuffer to record the request body and associates it with this instance.

        Note: you may not hold a reference to the returned CharBuffer as it will be reused.

        Note: this method is not thread safe

        Note: In order for the value written to the body buffer to be used, you must call endOfBufferInput(), which is the only valid way to invoke CharBuffer.flip() on the body buffer.

        Returns:
        a CharBuffer to record the request body
      • endOfBufferInput

        public void endOfBufferInput()
      • getBodyBuffer

        @Nullable
        public java.nio.CharBuffer getBodyBuffer()
        Returns the associated pooled CharBuffer to record the request body.

        Note: returns null unless withBodyBuffer() has previously been called

        Returns:
        a CharBuffer to record the request body, or null
      • getBodyBufferForSerialization

        @Nullable
        public java.lang.CharSequence getBodyBufferForSerialization()
        Returns the body buffer if it was written to and writing to it was finished through endOfBufferInput()
        Returns:
        body buffer if it was written to and writing was finished; returns null otherwise.
      • addHeader

        public Request addHeader​(java.lang.String headerName,
                                 @Nullable
                                 java.lang.String headerValue)
        Adds a request header.
        Parameters:
        headerName - The name of the header.
        headerValue - The value of the header.
        Returns:
        this, for fluent method chaining
      • addHeader

        public Request addHeader​(java.lang.String headerName,
                                 @Nullable
                                 java.util.Enumeration<java.lang.String> headerValues)
      • getHttpVersion

        @Nullable
        public java.lang.String getHttpVersion()
        HTTP version.
      • withHttpVersion

        public Request withHttpVersion​(@Nullable
                                       java.lang.String httpVersion)
      • getMethod

        @Nullable
        public java.lang.String getMethod()
        HTTP method. (Required)
      • withMethod

        public Request withMethod​(@Nullable
                                  java.lang.String method)
      • getSocket

        public Socket getSocket()
      • getUrl

        public Url getUrl()
        A complete Url, with scheme, host and path. (Required)
      • addCookie

        public Request addCookie​(java.lang.String cookieName,
                                 java.lang.String cookieValue)
      • resetState

        public void resetState()
        Description copied from interface: Recyclable
        resets pooled object state so it can be reused
        Specified by:
        resetState in interface Recyclable
      • copyFrom

        public void copyFrom​(Request other)
      • hasContent

        public boolean hasContent()