Package com.google.cloud.functions
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 interfaceHttpRequest.HttpPartRepresents one part inside a multipart (multipart/form-data) HTTP request.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods 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.StringgetMethod()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.StringgetPath()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.StringgetUri()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 Detail
-
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 ishttp://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 ishttp://foo.com/bar/baz?this=that, then this method will returnthis=that. If there is no query part, the returnedOptionalis 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 ishttp://foo.com/bar?thing=thing1&thing=thing2&cat=hat, then the returned map will mapthingto the list["thing1", "thing2"]andcatto the list with the single element"hat".- Returns:
- a map where each key is the name of a query parameter and the corresponding
Listvalue 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 ishttp://foo.com/bar?thing=thing1&thing=thing2&cat=hat, thengetFirstQueryParameter("thing")will returnOptional.of("thing1")andgetFirstQueryParameter("something")will returnOptional.empty(). This is a more convenient alternative togetQueryParameters().- 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 thecontent typeis notmultipart/form-data.
-
-