Class AbstractWebRequest

java.lang.Object
services.moleculer.web.servlet.request.AbstractWebRequest
All Implemented Interfaces:
HttpConstants, WebRequest
Direct Known Subclasses:
BlockingWebRequest, NonBlockingWebRequest

public abstract class AbstractWebRequest extends Object implements WebRequest, HttpConstants
  • Field Details

    • req

      protected final jakarta.servlet.http.HttpServletRequest req
    • protocol

      protected final String protocol
    • path

      protected final String path
    • query

      protected final String query
    • method

      protected final String method
    • contentLength

      protected final int contentLength
    • contentType

      protected final String contentType
    • multipart

      protected final boolean multipart
    • address

      protected final String address
    • headers

      protected final LinkedHashMap<String,String> headers
    • stream

      protected services.moleculer.stream.PacketStream stream
  • Constructor Details

    • AbstractWebRequest

      protected AbstractWebRequest(jakarta.servlet.http.HttpServletRequest req) throws IOException
      Throws:
      IOException
  • Method Details

    • getAddress

      public String getAddress()
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.
      Specified by:
      getAddress in interface WebRequest
      Returns:
      a String containing the IP address of the client that sent the request
    • getMethod

      public String getMethod()
      Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.
      Specified by:
      getMethod in interface WebRequest
      Returns:
      a String specifying the name of the method with which this request was made
    • getPath

      public String getPath()
      Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character.
      Specified by:
      getPath in interface WebRequest
      Returns:
      a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL
    • getQuery

      public String getQuery()
      Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.
      Specified by:
      getQuery in interface WebRequest
      Returns:
      a String containing the query string or null if the URL contains no query string. The value is not decoded by the container
    • getContentLength

      public int getContentLength()
      Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known ir is greater than Integer.MAX_VALUE. For HTTP servlets, same as the value of the CGI variable CONTENT_LENGTH.
      Specified by:
      getContentLength in interface WebRequest
      Returns:
      an integer containing the length of the request body or -1 if the length is not known or is greater than Integer.MAX_VALUE
    • getContentType

      public String getContentType()
      Returns the MIME type of the body of the request, or null if the type is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE.
      Specified by:
      getContentType in interface WebRequest
      Returns:
      a String containing the name of the MIME type of the request, or null if the type is not known
    • getBody

      public services.moleculer.stream.PacketStream getBody()
      Returns the request body as PacketStream.
      Specified by:
      getBody in interface WebRequest
      Returns:
      Request body (or null)
    • getHeader

      public String getHeader(String name)
      Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the request. The header name is case insensitive. You can use this method with any request header.
      Specified by:
      getHeader in interface WebRequest
      Parameters:
      name - name a String specifying the header name
      Returns:
      a String containing the value of the requested header, or null if the request does not have a header of that name
    • getHeaders

      public Iterator<String> getHeaders()
      Returns an iterator of all the header names this request contains. If the request has no headers, this method returns an empty iterator.
      Specified by:
      getHeaders in interface WebRequest
      Returns:
      an iterator of all the header names sent with this request; if the request has no headers, an empty iterator
    • getProtocol

      public String getProtocol()
      Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL.
      Specified by:
      getProtocol in interface WebRequest
      Returns:
      a String containing the protocol name and version number
    • isMultipart

      public boolean isMultipart()
      Checks if the Content-Type header defines a multipart request.
      Specified by:
      isMultipart in interface WebRequest
      Returns:
      true if the request is a multipart request, false otherwise
    • getInternalObject

      public Object getInternalObject()
      Returns the internal object of this WebRequest.
      Specified by:
      getInternalObject in interface WebRequest
      Returns:
      internal object (HttpServletRequest)