Interface HttpRequest

All Superinterfaces:
HttpMessage

public interface HttpRequest
extends HttpMessage
Represents the contents of an HTTP request that is being serviced by a Cloud Function.
  • Nested Class Summary

    Nested Classes
    Modifier and Type Interface Description
    static interface  HttpRequest.HttpPart
    Represents one part inside a multipart (multipart/form-data) HTTP request.
  • Method Summary

    Modifier and Type Method Description
    default java.util.Optional<java.lang.String> getFirstQueryParameter​(java.lang.String name)
    The first query parameter with the given name, if any.
    java.lang.String getMethod()
    The HTTP method of this request, such as "POST" or "GET".
    java.util.Map<java.lang.String,​HttpRequest.HttpPart> getParts()
    Returns the parts inside this multipart (multipart/form-data) HTTP request.
    java.lang.String getPath()
    The path part of the URI for this request, without any query.
    java.util.Optional<java.lang.String> getQuery()
    The query part of the URI for this request.
    java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getQueryParameters()
    The query parameters of this request.
    java.lang.String getUri()
    The full URI of this request as it arrived at the server.

    Methods inherited from interface com.google.cloud.functions.HttpMessage

    getCharacterEncoding, getContentLength, getContentType, getFirstHeader, getHeaders, getInputStream, getReader
  • Method Details

    • getMethod

      java.lang.String getMethod()
      The HTTP method of this request, such as "POST" or "GET".
      Returns:
      the HTTP method of this request.
    • getUri

      java.lang.String getUri()
      The full URI of this request as it arrived at the server.
      Returns:
      the full URI of this request.
    • getPath

      java.lang.String getPath()
      The path part of the URI for this request, without any query. If the full URI is http://foo.com/bar/baz?this=that, then this method will return /bar/baz.
      Returns:
      the path part of the URI for this request.
    • getQuery

      java.util.Optional<java.lang.String> getQuery()
      The query part of the URI for this request. If the full URI is http://foo.com/bar/baz?this=that, then this method will return this=that. If there is no query part, the returned Optional is empty.
      Returns:
      the query part of the URI, if any.
    • getQueryParameters

      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getQueryParameters()
      The query parameters of this request. If the full URI is http://foo.com/bar?thing=thing1&thing=thing2&cat=hat, then the returned map will map thing to the list ["thing1", "thing2"] and cat to the list with the single element "hat".
      Returns:
      a map where each key is the name of a query parameter and the corresponding List value indicates every value that was associated with that name.
    • getFirstQueryParameter

      default java.util.Optional<java.lang.String> getFirstQueryParameter​(java.lang.String name)
      The first query parameter with the given name, if any. If the full URI is http://foo.com/bar?thing=thing1&thing=thing2&cat=hat, then getFirstQueryParameter("thing") will return Optional.of("thing1") and getFirstQueryParameter("something") will return Optional.empty(). This is a more convenient alternative to getQueryParameters().
      Parameters:
      name - a query parameter name.
      Returns:
      the first query parameter value with the given name, if any.
    • getParts

      java.util.Map<java.lang.String,​HttpRequest.HttpPart> getParts()
      Returns the parts inside this multipart (multipart/form-data) HTTP request. Each entry in the returned map has the name of the part as its key and the contents as the associated value.
      Returns:
      a map from part names to part contents.
      Throws:
      java.lang.IllegalStateException - if the content type is not multipart/form-data.