433089 - Client should provide Request.accept() method, like JAX-RS 2.0 Invocation.Builder.accept().
This commit is contained in:
parent
fa51281546
commit
b603964bb6
|
@ -242,6 +242,21 @@ public class HttpRequest implements Request
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request accept(String... accepts)
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String accept : accepts)
|
||||
{
|
||||
if (result.length() > 0)
|
||||
result.append(", ");
|
||||
result.append(accept);
|
||||
}
|
||||
if (result.length() > 0)
|
||||
headers.put(HttpHeader.ACCEPT, result.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request header(String name, String value)
|
||||
{
|
||||
|
|
|
@ -230,11 +230,18 @@ public interface Request
|
|||
String getAgent();
|
||||
|
||||
/**
|
||||
* @param agent the user agent for this request
|
||||
* @param agent the user agent for this request (corresponds to the {@code User-Agent} header)
|
||||
* @return this request object
|
||||
*/
|
||||
Request agent(String agent);
|
||||
|
||||
/**
|
||||
* @param accepts the content types that are acceptable in the response, such as
|
||||
* "text/plain;q=0.5" or "text/html" (corresponds to the {@code Accept} header)
|
||||
* @return this request object
|
||||
*/
|
||||
Request accept(String... accepts);
|
||||
|
||||
/**
|
||||
* @return the idle timeout for this request, in milliseconds
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue