本文整理匯總了Java中org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientInvocation.getEntity方法的具體用法?Java ClientInvocation.getEntity怎麽用?Java ClientInvocation.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jboss.resteasy.client.jaxrs.internal.ClientInvocation
的用法示例。
在下文中一共展示了ClientInvocation.getEntity方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadHttpMethod
import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; //導入方法依賴的package包/類
protected void loadHttpMethod(final ClientInvocation request, HttpRequestBase httpMethod)
throws Exception {
if (request.getEntity() != null) {
if (httpMethod instanceof HttpGet) {
throw new ProcessingException("A GET request cannot have a body.");
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
request.getDelegatingOutputStream().setDelegate(baos);
try {
HttpEntity entity = buildEntity(request);
HttpPost post = (HttpPost) httpMethod;
commitHeaders(request, httpMethod);
post.setEntity(entity);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else // no body
{
commitHeaders(request, httpMethod);
}
}
示例2: createRequest
import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; //導入方法依賴的package包/類
private MockHttpRequest createRequest(ClientInvocation request) {
MockHttpRequest mockRequest =
MockHttpRequest.create(request.getMethod(), request.getUri(), baseUri);
if (request.getEntity() != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
request.getDelegatingOutputStream().setDelegate(baos);
try {
request.writeRequestBody(request.getEntityStream());
baos.close();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
mockRequest.setInputStream(new ByteArrayInputStream(baos.toByteArray()));
}
MultivaluedMap<String, String> requestHeaders = request.getHeaders().asMap();
mockRequest.getMutableHeaders().putAll(requestHeaders);
copyCookies(mockRequest, requestHeaders);
return mockRequest;
}
示例3: createRequestBody
import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation; //導入方法依賴的package包/類
private RequestBody createRequestBody(final ClientInvocation request) {
if (request.getEntity() == null) {
return null;
}
// NOTE: this will invoke WriterInterceptors which can possibly change the request,
// so it must be done first, before reading any header.
final Buffer buffer = new Buffer();
try {
request.writeRequestBody(buffer.outputStream());
} catch (IOException e) {
throw new RuntimeException(e);
}
javax.ws.rs.core.MediaType mediaType = request.getHeaders().getMediaType();
final MediaType contentType =
(mediaType == null) ? null : MediaType.parse(mediaType.toString());
return new RequestBody() {
@Override
public long contentLength() throws IOException {
return buffer.size();
}
@Override
public MediaType contentType() {
return contentType;
}
@Override
public void writeTo(BufferedSink sink) throws IOException {
buffer.copyTo(sink.buffer(), 0, buffer.size());
}
};
}