Package org.eclipse.sw360.http
Interface RequestBuilder
-
public interface RequestBuilderAn interface that allows the definition of HTTP requests to be executed.
This interface provides methods to set the single properties of an HTTP request. This can be done in a convenient way using method chaining. A client only has to set the properties that are relevant for a specific request; as a minimum, the request URI must be set. Note that there is no
build()method to conclude the definition of the request; this is not necessary as the HTTP client can figure out itself when to collect the properties that have been defined.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classRequestBuilder.MethodAn enumeration class for the HTTP methods supported by the HTTP client.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RequestBuilderbody(Consumer<RequestBodyBuilder> bodyProducer)Adds a request body to this builder.RequestBuilderheader(String name, String value)Sets a request header.RequestBuildermethod(RequestBuilder.Method method)Sets the HTTP method to be used for the request.RequestBuildermultiPart(String name, Consumer<RequestBodyBuilder> partProducer)Adds a part of a multi-part request to this builder.RequestBuilderuri(String uri)Set the URI for the request.
-
-
-
Method Detail
-
method
RequestBuilder method(RequestBuilder.Method method)
Sets the HTTP method to be used for the request. If no method is set explicitly, the default is GET.- Parameters:
method- the HTTP method for the request- Returns:
- this request builder
-
uri
RequestBuilder uri(String uri)
Set the URI for the request.- Parameters:
uri- the request URI- Returns:
- this request builder
-
header
RequestBuilder header(String name, String value)
Sets a request header.- Parameters:
name- the header namevalue- the header value- Returns:
- this request builder
-
body
RequestBuilder body(Consumer<RequestBodyBuilder> bodyProducer)
Adds a request body to this builder. The consumer passed to this method is invoked with aRequestBodyBuilderwhich can be used to define the request body. Use this method to define request bodies for simple requests; for multi-part requests,multiPart(String, Consumer)has to be used instead.- Parameters:
bodyProducer- the producer for the request body- Returns:
- this request builder
-
multiPart
RequestBuilder multiPart(String name, Consumer<RequestBodyBuilder> partProducer)
Adds a part of a multi-part request to this builder. When using this method, a multi-part request is generated. It has to be called for each part. The single parts are defined via consumer objects that are passedRequestPartBuilderinstances for the definition of the parts.- Parameters:
name- the name of the partpartProducer- the producer for the request part- Returns:
- this request builder
-
-