类 DefaultRestClient.DefaultRequestBodyUriSpec
- 所有已实现的接口:
RestClient.RequestBodySpec,RestClient.RequestBodyUriSpec,RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>,RestClient.RequestHeadersUriSpec<RestClient.RequestBodySpec>,RestClient.UriSpec<RestClient.RequestBodySpec>
- 封闭类:
- DefaultRestClient
-
嵌套类概要
嵌套类从接口继承的嵌套类/接口 cn.taketoday.web.client.RestClient.RequestHeadersSpec
RestClient.RequestHeadersSpec.ExchangeFunction<T> -
字段概要
字段修饰符和类型字段说明private HttpHeadersprivate final HttpMethodprivate Consumer<ClientHttpRequest>private URI -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明Set the list of acceptable media types, as specified by theAcceptheader.acceptCharset(Charset... acceptableCharsets) Set the list of acceptable charsets, as specified by theAccept-Charsetheader.Set the attribute with the given name to the given value.attributes(Consumer<Map<String, Object>> attributesConsumer) Provides access to every attribute declared so far with the possibility to add, replace, or remove values.Set the body of the response to the given function that writes to anOutputStream.Set the body of the request to the givenObject.body(T body, cn.taketoday.core.ParameterizedTypeReference<T> bodyType) Set the body of the response to the givenObject.contentLength(long contentLength) Set the length of the body in bytes, as specified by theContent-Lengthheader.contentType(MediaType contentType) Set the media type of the body, as specified by theContent-Typeheader.private ClientHttpRequestcreateRequest(URI uri) private static ResourceAccessExceptioncreateResourceAccessException(URI url, HttpMethod method, IOException ex) <T> Texchange(RestClient.RequestHeadersSpec.ExchangeFunction<T> exchangeFunction, boolean close) Exchange theClientHttpResponsefor a typeT.private <T> TexchangeInternal(RestClient.RequestHeadersSpec.ExchangeFunction<T> exchangeFunction, boolean close) voidexecute()Execute the HTTP request:voidexecute(boolean close) Execute the HTTP request:private HttpHeadersAdd the given, single header value under the given name.headers(Consumer<HttpHeaders> headersConsumer) Provides access to every header declared so far with the possibility to add, replace, or remove values.httpRequest(Consumer<ClientHttpRequest> requestConsumer) Callback for access to theClientHttpRequestthat in turn provides access to the native request of the underlying HTTP library.ifModifiedSince(ZonedDateTime ifModifiedSince) Set the value of theIf-Modified-Sinceheader.ifNoneMatch(String... ifNoneMatches) Set the values of theIf-None-Matchheader.private HttpHeadersprivate URIinitUri()private voidlogBody(Object body, MediaType mediaType, HttpMessageConverter<?> converter) retrieve()Proceed to declare how to extract the response.Specify the URI for the request using a URI template and URI variables.uri(String uriTemplate, Function<UriBuilder, URI> uriFunction) Specify the URI starting with a URI template and finishing off with aUriBuildercreated from the template.Specify the URI for the request using a URI template and URI variables.Specify the URI using an absolute, fully constructedURI.uri(Function<UriBuilder, URI> uriFunction) Specify the URI by through aUriBuilder.private voidwriteWithMessageConverters(Object body, Type bodyType, ClientHttpRequest clientRequest) 从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.web.client.RestClient.RequestHeadersSpec
exchange
-
字段详细资料
-
httpMethod
-
uri
-
headers
-
body
-
attributes
-
httpRequestConsumer
-
-
构造器详细资料
-
DefaultRequestBodyUriSpec
-
-
方法详细资料
-
uri
从接口复制的说明:RestClient.UriSpecSpecify the URI for the request using a URI template and URI variables.If a
UriBuilderFactorywas configured for the client (e.g. with a base URI) it will be used to expand the URI template.- 指定者:
uri在接口中RestClient.UriSpec<RestClient.RequestBodySpec>
-
uri
从接口复制的说明:RestClient.UriSpecSpecify the URI for the request using a URI template and URI variables.If a
UriBuilderFactorywas configured for the client (e.g. with a base URI) it will be used to expand the URI template.- 指定者:
uri在接口中RestClient.UriSpec<RestClient.RequestBodySpec>
-
uri
从接口复制的说明:RestClient.UriSpecSpecify the URI starting with a URI template and finishing off with aUriBuildercreated from the template.- 指定者:
uri在接口中RestClient.UriSpec<RestClient.RequestBodySpec>
-
uri
从接口复制的说明:RestClient.UriSpecSpecify the URI by through aUriBuilder. -
uri
从接口复制的说明:RestClient.UriSpecSpecify the URI using an absolute, fully constructedURI.- 指定者:
uri在接口中RestClient.UriSpec<RestClient.RequestBodySpec>
-
getHeaders
-
header
public DefaultRestClient.DefaultRequestBodyUriSpec header(String headerName, String... headerValues) 从接口复制的说明:RestClient.RequestHeadersSpecAdd the given, single header value under the given name.- 指定者:
header在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
headerName- the header nameheaderValues- the header value(s)- 返回:
- this builder
-
headers
从接口复制的说明:RestClient.RequestHeadersSpecProvides access to every header declared so far with the possibility to add, replace, or remove values.- 指定者:
headers在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
headersConsumer- the consumer to provide access to- 返回:
- this builder
-
accept
从接口复制的说明:RestClient.RequestHeadersSpecSet the list of acceptable media types, as specified by theAcceptheader.- 指定者:
accept在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
acceptableMediaTypes- the acceptable media types- 返回:
- this builder
-
acceptCharset
从接口复制的说明:RestClient.RequestHeadersSpecSet the list of acceptable charsets, as specified by theAccept-Charsetheader.- 指定者:
acceptCharset在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
acceptableCharsets- the acceptable charsets- 返回:
- this builder
-
contentType
从接口复制的说明:RestClient.RequestBodySpecSet the media type of the body, as specified by theContent-Typeheader.- 指定者:
contentType在接口中RestClient.RequestBodySpec- 参数:
contentType- the content type- 返回:
- this builder
- 另请参阅:
-
contentLength
从接口复制的说明:RestClient.RequestBodySpecSet the length of the body in bytes, as specified by theContent-Lengthheader.- 指定者:
contentLength在接口中RestClient.RequestBodySpec- 参数:
contentLength- the content length- 返回:
- this builder
- 另请参阅:
-
ifModifiedSince
从接口复制的说明:RestClient.RequestHeadersSpecSet the value of theIf-Modified-Sinceheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
- 指定者:
ifModifiedSince在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
ifModifiedSince- the new value of the header- 返回:
- this builder
-
ifNoneMatch
从接口复制的说明:RestClient.RequestHeadersSpecSet the values of theIf-None-Matchheader.- 指定者:
ifNoneMatch在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
ifNoneMatches- the new value of the header- 返回:
- this builder
-
attribute
从接口复制的说明:RestClient.RequestHeadersSpecSet the attribute with the given name to the given value.- 指定者:
attribute在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
name- the name of the attribute to addvalue- the value of the attribute to add- 返回:
- this builder
-
attributes
从接口复制的说明:RestClient.RequestHeadersSpecProvides access to every attribute declared so far with the possibility to add, replace, or remove values.- 指定者:
attributes在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
attributesConsumer- the consumer to provide access to- 返回:
- this builder
-
httpRequest
从接口复制的说明:RestClient.RequestHeadersSpecCallback for access to theClientHttpRequestthat in turn provides access to the native request of the underlying HTTP library.This could be useful for setting advanced, per-request options that are exposed by the underlying library.
- 指定者:
httpRequest在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
requestConsumer- a consumer to access theClientHttpRequestwith- 返回:
- this builder
-
body
从接口复制的说明:RestClient.RequestBodySpecSet the body of the request to the givenObject. For example:Person person = ... ; ResponseEntity<Void> response = client.post() .uri("/persons/{id}", id) .contentType(MediaType.APPLICATION_JSON) .body(person) .retrieve() .toBodilessEntity();- 指定者:
body在接口中RestClient.RequestBodySpec- 参数:
body- the body of the response- 返回:
- the built response
-
body
public <T> RestClient.RequestBodySpec body(T body, cn.taketoday.core.ParameterizedTypeReference<T> bodyType) 从接口复制的说明:RestClient.RequestBodySpecSet the body of the response to the givenObject. The parameterbodyTypeis used to capture the generic type.- 指定者:
body在接口中RestClient.RequestBodySpec- 参数:
body- the body of the responsebodyType- the type of the body, used to capture the generic type- 返回:
- the built response
-
body
从接口复制的说明:RestClient.RequestBodySpecSet the body of the response to the given function that writes to anOutputStream.- 指定者:
body在接口中RestClient.RequestBodySpec- 参数:
body- a function that takes anOutputStreamand can throw anIOException- 返回:
- the built response
-
writeWithMessageConverters
private void writeWithMessageConverters(Object body, Type bodyType, ClientHttpRequest clientRequest) throws IOException - 抛出:
IOException
-
logBody
-
retrieve
从接口复制的说明:RestClient.RequestHeadersSpecProceed to declare how to extract the response. For example to extract aResponseEntitywith status, headers, and body:ResponseEntity<Person> entity = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .retrieve() .toEntity(Person.class);Or if interested only in the body:
Person person = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .retrieve() .body(Person.class);By default, 4xx response code result in a
HttpClientErrorExceptionand 5xx response codes in aHttpServerErrorException. To customize error handling, useonStatushandlers.- 指定者:
retrieve在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 返回:
ResponseSpecto specify how to decode the body
-
execute
public void execute()从接口复制的说明:RestClient.RequestHeadersSpecExecute the HTTP request:client.delete() .uri("/persons/1") .execute();Or if interested only in the body:
client.put() .uri("/persons/1") .body(persons) .execute();By default, 4xx response code result in a
HttpClientErrorExceptionand 5xx response codes in aHttpServerErrorException. To customize error handling, useonStatushandlers. -
execute
public void execute(boolean close) 从接口复制的说明:RestClient.RequestHeadersSpecExecute the HTTP request:client.delete() .uri("/persons/1") .execute();Or if interested only in the body:
client.put() .uri("/persons/1") .body(persons) .execute();By default, 4xx response code result in a
HttpClientErrorExceptionand 5xx response codes in aHttpServerErrorException. To customize error handling, useonStatushandlers.- 指定者:
execute在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 参数:
close-trueto close the response
-
exchange
public <T> T exchange(RestClient.RequestHeadersSpec.ExchangeFunction<T> exchangeFunction, boolean close) 从接口复制的说明:RestClient.RequestHeadersSpecExchange theClientHttpResponsefor a typeT. This can be useful for advanced scenarios, for example to decode the response differently depending on the response status:Person person = client.get() .uri("/people/1") .accept(MediaType.APPLICATION_JSON) .exchange((request, response) -> { if (response.getStatusCode().equals(HttpStatus.OK)) { return deserialize(response.getBody()); } else { throw new BusinessException(); } });Note: If
closeistrue, then the response is closed after the exchange function has been invoked. When set tofalse, the caller is responsible for closing the response.- 指定者:
exchange在接口中RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>- 类型参数:
T- the type the response will be transformed to- 参数:
exchangeFunction- the function to handle the response withclose-trueto close the response afterexchangeFunctionis invoked,falseto keep it open- 返回:
- the value returned from the exchange function
-
exchangeInternal
private <T> T exchangeInternal(RestClient.RequestHeadersSpec.ExchangeFunction<T> exchangeFunction, boolean close) -
initUri
-
initHeaders
-
createRequest
- 抛出:
IOException
-
createResourceAccessException
private static ResourceAccessException createResourceAccessException(URI url, HttpMethod method, IOException ex)
-