Package com.yahoo.container.jdisc
Class HttpRequest.Builder
- java.lang.Object
-
- com.yahoo.container.jdisc.HttpRequest.Builder
-
- Enclosing class:
- HttpRequest
public static class HttpRequest.Builder extends java.lang.Object
Builder of HTTP requests
-
-
Constructor Summary
Constructors Constructor Description Builder(HttpRequest request)
Instantiate a request builder with defaults from an existing request.Builder(com.yahoo.jdisc.http.HttpRequest request)
Instantiate a request builder with defaults from an existing request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpRequest
createClientRequest()
Start of API for synchronous HTTP request dispatch.HttpRequest
createDirectRequest()
Create a new HTTP request without creating a new JDisc request.HttpRequest
createServerRequest()
Start of API for synchronous HTTP request dispatch.HttpRequest.Builder
jdiscRequest(com.yahoo.jdisc.http.HttpRequest request)
Define the JDisc parent request.HttpRequest.Builder
method(com.yahoo.jdisc.http.HttpRequest.Method method)
Set the HTTP method for the new request.HttpRequest.Builder
put(java.lang.String key, java.lang.String value)
Add a parameter to the request.HttpRequest.Builder
removeProperty(java.lang.String parameterName)
Removes the parameter from the request properties.HttpRequest.Builder
requestData(java.io.InputStream requestData)
Set an inputstream to use for the request.HttpRequest.Builder
uri(java.net.URI uri)
Set the URI of the server request created.
-
-
-
Constructor Detail
-
Builder
public Builder(HttpRequest request)
Instantiate a request builder with defaults from an existing request. If the request is null, a JDisc request must be set explitly usingjdiscRequest(com.yahoo.jdisc.http.HttpRequest)
before instantiating any HTTP request.- Parameters:
request
- source for defaults and parent JDisc request, may be null- See Also:
HttpRequest.createTestRequest(String, com.yahoo.jdisc.http.HttpRequest.Method)
-
Builder
public Builder(com.yahoo.jdisc.http.HttpRequest request)
Instantiate a request builder with defaults from an existing request.- Parameters:
request
- parent JDisc request- See Also:
HttpRequest.createTestRequest(String, com.yahoo.jdisc.http.HttpRequest.Method)
-
-
Method Detail
-
put
public HttpRequest.Builder put(java.lang.String key, java.lang.String value)
Add a parameter to the request. Multi-value parameters are not supported.- Parameters:
key
- parameter namevalue
- parameter value- Returns:
- this Builder instance
-
removeProperty
public HttpRequest.Builder removeProperty(java.lang.String parameterName)
Removes the parameter from the request properties. If there is no such parameter, nothing will be done.
-
method
public HttpRequest.Builder method(com.yahoo.jdisc.http.HttpRequest.Method method)
Set the HTTP method for the new request.- Parameters:
method
- the HTTP method to use for the new request- Returns:
- this Builder instance
-
jdiscRequest
public HttpRequest.Builder jdiscRequest(com.yahoo.jdisc.http.HttpRequest request)
Define the JDisc parent request.- Parameters:
request
- a valid JDisc request for the current container- Returns:
- this Builder instance
-
requestData
public HttpRequest.Builder requestData(java.io.InputStream requestData)
Set an inputstream to use for the request. If not set, the data from the original HttpRequest is used.- Parameters:
requestData
- data to be consumed, e.g. POST data- Returns:
- this Builder instance
-
uri
public HttpRequest.Builder uri(java.net.URI uri)
Set the URI of the server request created.- Parameters:
uri
- a valid URI for a server request- Returns:
- this Builder instance
-
createDirectRequest
public HttpRequest createDirectRequest()
Create a new HTTP request without creating a new JDisc request. This is for scenarios where another HTTP request handler is invoked directly without dispatching through JDisc. The parent JDisc request for the original HttpRequest will be passed on the new HttpRequest instance's JDisc request, but no properties will be propagated into the original JDisc request.- Returns:
- a new HttpRequest instance reflecting the given request data and parameters
-
createClientRequest
public HttpRequest createClientRequest()
Start of API for synchronous HTTP request dispatch. Not yet ready for use.- Returns:
- a new client request
-
createServerRequest
public HttpRequest createServerRequest()
Start of API for synchronous HTTP request dispatch. Not yet ready for use.- Returns:
- a new server request
-
-