Class HttpRequest.Builder
- java.lang.Object
-
- com.mongodb.stitch.core.services.http.HttpRequest.Builder
-
- Enclosing class:
- HttpRequest
public static class HttpRequest.Builder extends Object
A builder that can buildHttpRequests.
-
-
Constructor Summary
Constructors Constructor Description Builder()Constructs a new builder for an HTTP request.
-
Method Summary
Modifier and Type Method Description HttpRequestbuild()Builds, validates, and returns theHttpRequest.HttpRequest.BuilderwithAuthUrl(String authUrl)Sets the URL that will be used to capture cookies for authentication before the actual request is executed.HttpRequest.BuilderwithBody(Object body)Sets the body that will be included in the request.HttpRequest.BuilderwithCookies(Map<String,String> cookies)Sets the cookies that will be included in the request.HttpRequest.BuilderwithEncodeBodyAsJson(Boolean encodeBodyAsJson)Sets whether or not the included body should be encoded as extended JSON when sent to the url in this request.HttpRequest.BuilderwithFollowRedirects(Boolean followRedirects)Sets whether or not Stitch should follow redirects while executing the request.HttpRequest.BuilderwithForm(Map<String,String> form)Sets the form that will be included in the request.HttpRequest.BuilderwithHeaders(Map<String,Collection<String>> headers)Sets the headers that will be included in the request.HttpRequest.BuilderwithMethod(HttpMethod method)Sets the HTTP method of the request.HttpRequest.BuilderwithUrl(String url)Sets the URL that the request will be performed against.
-
-
-
Method Detail
-
withUrl
public HttpRequest.Builder withUrl(String url)
Sets the URL that the request will be performed against.- Parameters:
url- the URL that the request will be performed against.- Returns:
- the builder.
-
withMethod
public HttpRequest.Builder withMethod(HttpMethod method)
Sets the HTTP method of the request.- Parameters:
method- the HTTP method of the request.- Returns:
- the builder.
-
withAuthUrl
public HttpRequest.Builder withAuthUrl(String authUrl)
Sets the URL that will be used to capture cookies for authentication before the actual request is executed.- Parameters:
authUrl- the URL that will be used to capture cookies for authentication before the actual request is executed.- Returns:
- the builder.
-
withHeaders
public HttpRequest.Builder withHeaders(Map<String,Collection<String>> headers)
Sets the headers that will be included in the request.- Parameters:
headers- the headers that will be included in the request.- Returns:
- the builder.
-
withCookies
public HttpRequest.Builder withCookies(Map<String,String> cookies)
Sets the cookies that will be included in the request.- Parameters:
cookies- the cookies that will be included in the request.- Returns:
- the builder.
-
withBody
public HttpRequest.Builder withBody(Object body)
Sets the body that will be included in the request. If encodeBodyAsJson is not set (or is set to false) the body must either be aStringor aBinaryor else the request will fail when executed on Stitch.- Parameters:
body- the body that will be included in the request.- Returns:
- the builder.
-
withEncodeBodyAsJson
public HttpRequest.Builder withEncodeBodyAsJson(Boolean encodeBodyAsJson)
Sets whether or not the included body should be encoded as extended JSON when sent to the url in this request. Defaults to false.- Parameters:
encodeBodyAsJson- whether or not the included body should be encoded as extended JSON when sent to the url in this request.- Returns:
- the builder.
- See Also:
withBody
-
withForm
public HttpRequest.Builder withForm(Map<String,String> form)
Sets the form that will be included in the request.- Parameters:
form- the form that will be included in the request.- Returns:
- the builder.
-
withFollowRedirects
public HttpRequest.Builder withFollowRedirects(Boolean followRedirects)
Sets whether or not Stitch should follow redirects while executing the request. Defaults to false.- Parameters:
followRedirects- whether or not Stitch should follow redirects while executing the request. Defaults to false.- Returns:
- the builder.
-
build
public HttpRequest build()
Builds, validates, and returns theHttpRequest.- Returns:
- the built HTTP request.
-
-