public class HttpRequestBuilders extends Object implements RequestBuilder
HttpRequestBase required as input to
perform request in WebTemplate.
Application tests will typically access this builder through the static
factory methods in TestRequestBuilders.| 限定符和类型 | 方法和说明 |
|---|---|
HttpRequestBuilders |
accept(String... mediaTypes)
Set the 'Accept' header to the given media type(s).
|
HttpRequestBuilders |
body(byte[] content)
Set the request body.
|
HttpRequestBuilders |
body(String content)
Set the request body.
|
HttpRequestBuilders |
body(String param,
Collection<String> values) |
HttpRequestBuilders |
body(String param,
String value)
Set the request body form.
|
org.apache.http.HttpRequest |
buildRequest() |
HttpRequestBuilders |
characterEncoding(String encoding)
Set the character encoding of the request.
|
HttpRequestBuilders |
contentType(String contentType)
Set the 'Content-Type' header of the request.
|
HttpRequestBuilders |
cookie(org.apache.http.cookie.Cookie... cookies)
Add the given cookies to the request.
|
String |
getRequestDescription() |
HttpRequestBuilders |
header(String name,
Object... values)
Add a header to the request.
|
HttpRequestBuilders |
locale(Locale locale)
Set the locale of the request.
|
HttpRequestBuilders |
param(String name,
Collection<String> values)
Add a multi value request parameter to
HttpRequestBuilders. |
HttpRequestBuilders |
param(String name,
String value)
Add a request parameter to the
HttpRequestBuilders. |
HttpRequestBuilders |
path(String name,
String value)
Replace a section of path in the uriTemplate
|
HttpRequestBuilders |
with(RequestPostProcessor postProcessor)
An extension point for further initialization of
HttpRequestBase
in ways not built directly into the MockHttpServletRequestBuilder. |
public org.apache.http.HttpRequest buildRequest()
throws Exception
buildRequest 在接口中 RequestBuilderExceptionpublic String getRequestDescription()
getRequestDescription 在接口中 RequestBuilderpublic HttpRequestBuilders param(String name, String value)
HttpRequestBuilders.
If called more than once, the new values are added.name - the parameter namevalue - the parameter valuepublic HttpRequestBuilders param(String name, Collection<String> values)
HttpRequestBuilders.name - the parameter namevalues - multi values of the parameterpublic HttpRequestBuilders path(String name, String value)
name - replacement expressionvalue - replacement valuepublic HttpRequestBuilders header(String name, Object... values)
name - the header namevalues - one or more header valuespublic HttpRequestBuilders contentType(String contentType)
contentType - the bytesContent typepublic HttpRequestBuilders accept(String... mediaTypes)
mediaTypes - one or more media typespublic HttpRequestBuilders body(byte[] content)
TestRequestBuilders.api(Class).content - the body bytesContentpublic HttpRequestBuilders body(String content)
body(byte[]) and reset content set by
body(String, String).content - the body bytesContentpublic HttpRequestBuilders body(String param, String value)
body(byte[]) or body(String),
this method has the lowest priority.param - the body form parametervalue - the body form valuepublic HttpRequestBuilders body(String param, Collection<String> values)
public HttpRequestBuilders cookie(org.apache.http.cookie.Cookie... cookies)
cookies - the cookies to addpublic HttpRequestBuilders locale(Locale locale)
locale - the localepublic HttpRequestBuilders characterEncoding(String encoding)
encoding - the character encodingpublic HttpRequestBuilders with(RequestPostProcessor postProcessor)
HttpRequestBase
in ways not built directly into the MockHttpServletRequestBuilder.
Implementation of this interface can have builder-style methods themselves
and be made accessible through static factory methods.postProcessor - a post-processor to addCopyright © 2016. All rights reserved.