Package com.azure.common.http
Class HttpRequest
- java.lang.Object
-
- com.azure.common.http.HttpRequest
-
public class HttpRequest extends Object
The outgoing Http request.
-
-
Constructor Summary
Constructors Constructor Description HttpRequest(HttpMethod httpMethod, URL url)Create a new HttpRequest instance.HttpRequest(HttpMethod httpMethod, URL url, HttpHeaders headers, reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> body)Create a new HttpRequest instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Flux<io.netty.buffer.ByteBuf>body()Get the request content.HttpRequestbuffer()Creates a clone of the request.HttpHeadersheaders()Get the request headers.HttpMethodhttpMethod()Get the request method.URLurl()Get the target address.HttpRequestwithBody(byte[] content)Set the request content.HttpRequestwithBody(String content)Set the request content.HttpRequestwithBody(reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> content)Set request content.HttpRequestwithHeader(String name, String value)Set a request header, replacing any existing value.HttpRequestwithHeaders(HttpHeaders headers)Set the request headers.HttpRequestwithHttpMethod(HttpMethod httpMethod)Set the request method.HttpRequestwithUrl(URL url)Set the target address to send the request to.
-
-
-
Constructor Detail
-
HttpRequest
public HttpRequest(HttpMethod httpMethod, URL url)
Create a new HttpRequest instance.- Parameters:
httpMethod- the HTTP request methodurl- the target address to send the request to
-
HttpRequest
public HttpRequest(HttpMethod httpMethod, URL url, HttpHeaders headers, reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> body)
Create a new HttpRequest instance.- Parameters:
httpMethod- the HTTP request methodurl- the target address to send the request toheaders- the HTTP headers to use with this requestbody- the request content
-
-
Method Detail
-
httpMethod
public HttpMethod httpMethod()
Get the request method.- Returns:
- the request method
-
withHttpMethod
public HttpRequest withHttpMethod(HttpMethod httpMethod)
Set the request method.- Parameters:
httpMethod- the request method- Returns:
- this HttpRequest
-
url
public URL url()
Get the target address.- Returns:
- the target address
-
withUrl
public HttpRequest withUrl(URL url)
Set the target address to send the request to.- Parameters:
url- target address asURL- Returns:
- this HttpRequest
-
headers
public HttpHeaders headers()
Get the request headers.- Returns:
- headers to be sent
-
withHeaders
public HttpRequest withHeaders(HttpHeaders headers)
Set the request headers.- Parameters:
headers- the set of headers- Returns:
- this HttpRequest
-
withHeader
public HttpRequest withHeader(String name, String value)
Set a request header, replacing any existing value. A null forvaluewill remove the header if one with matching name exists.- Parameters:
name- the header namevalue- the header value- Returns:
- this HttpRequest
-
body
public reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> body()
Get the request content.- Returns:
- the content to be send
-
withBody
public HttpRequest withBody(String content)
Set the request content.- Parameters:
content- the request content- Returns:
- this HttpRequest
-
withBody
public HttpRequest withBody(byte[] content)
Set the request content. The Content-Length header will be set based on the given content's length- Parameters:
content- the request content- Returns:
- this HttpRequest
-
withBody
public HttpRequest withBody(reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> content)
Set request content. Caller must set the Content-Length header to indicate the length of the content, or use Transfer-Encoding: chunked.- Parameters:
content- the request content- Returns:
- this HttpRequest
-
buffer
public HttpRequest buffer()
Creates a clone of the request. The main purpose of this is so that this HttpRequest can be changed and the resulting HttpRequest can be a backup. This means that the buffered HttpHeaders and body must not be able to change from side effects of this HttpRequest.- Returns:
- a new HTTP request instance with cloned instances of all mutable properties.
-
-