当前位置: 首页>>代码示例>>Java>>正文


Java ClientInvocation.getEntity方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:23,代码来源:ApacheHttpClient4Dot3Engine.java

示例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;
}
 
开发者ID:tbroyer,项目名称:jaxrs-utils,代码行数:23,代码来源:InProcessClientHttpEngine.java

示例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());
    }
  };
}
 
开发者ID:tbroyer,项目名称:jaxrs-utils,代码行数:36,代码来源:OkHttpClientEngine.java


注:本文中的org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.getEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。