Interface HttpRequest.Builder
- Enclosing interface:
- HttpRequest
public static interface HttpRequest.Builder
Builder of HTTP requests.
-
Method Summary
Modifier and TypeMethodDescriptionSet the Accept header.body(HttpRequest.BodyProcessor bodyProcessor) contentType(String contentType) Set the Content-Type header.expectContinue(boolean enable) followRedirects(HttpClient.Redirect policy) get()Send a GET request to the configured endpoint.Set a header value.Set several values for a header.Send a request to the configured endpoint using the given HTTP method.post()Send a POST request to the configured endpoint.put()Send a PUT request to the configured endpoint.socketTimeout(Duration duration) Set a timeout for receiving data after connection has been established for this request.Set a timeout for this request.withoutAlarm(AlarmType alarmType) Don't raise or clear any alarms of the givenAlarmTypefor this request.Don't raise or clear any alarms for this request.
-
Method Details
-
body
-
expectContinue
-
header
Set a header value.Any other values previously set are overwritten.
- Parameters:
headerName- name of the headervalue- value of the header- Returns:
- this builder
-
header
-
header
Set several values for a header.Any other values previously set are overwritten.
- Parameters:
headerName- name of the headervalues- values of the header- Returns:
- this builder
-
accept
Set the Accept header.- Parameters:
acceptHeader- value for the Accept header- Returns:
- this builder
- See Also:
-
contentType
Set the Content-Type header.When calling this method, ensure to set the body to be sent.
- Parameters:
contentType- content type of the request body.- Returns:
- this builder
-
timeout
Set a timeout for this request.- Parameters:
duration- maximum duration to wait for a response- Returns:
- this builder
-
socketTimeout
Set a timeout for receiving data after connection has been established for this request. Normally, timeouts are configured per Http client, however their might be some exceptional use-cases for which setting a timeout for a specific request is desired.- Parameters:
duration- maximum duration to wait for data- Returns:
- this builder
- Since:
- 5.3.0
-
followRedirects
- Parameters:
policy- the redirect policy for this request- Returns:
- this builder
-
withoutAlarms
HttpRequest.Builder withoutAlarms()Don't raise or clear any alarms for this request.- Returns:
- this builder
- Since:
- 5.2.0
-
withoutAlarm
Don't raise or clear any alarms of the givenAlarmTypefor this request. Calling this method multiple times has a cumulative effect.- Parameters:
alarmType- the type of alarm not to raise or clear- Returns:
- this builder
- Since:
- 5.3.0
-
method
Send a request to the configured endpoint using the given HTTP method.- Parameters:
method- HTTP method- Returns:
- http response
-
get
HttpRequest get()Send a GET request to the configured endpoint.- Returns:
- http response
-
post
HttpRequest post()Send a POST request to the configured endpoint.- Returns:
- http response
-
put
HttpRequest put()Send a PUT request to the configured endpoint.- Returns:
- http response
-