org.restlet.data.Request.isEntityAvailable()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(250)

本文整理了Java中org.restlet.data.Request.isEntityAvailable方法的一些代码示例,展示了Request.isEntityAvailable的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.isEntityAvailable方法的具体详情如下:
包路径:org.restlet.data.Request
类名称:Request
方法名:isEntityAvailable

Request.isEntityAvailable介绍

[英]Indicates if a content is available and can be sent. Several conditions must be met: the method must allow the sending of content, the content must exists and have some available data.
[中]指示内容是否可用并可以发送。必须满足几个条件:方法必须允许发送内容,内容必须存在并且具有一些可用数据。

代码示例

代码示例来源:origin: org.restlet/org.restlet

/**
 * Indicates if a content is available and can be sent. Several conditions
 * must be met: the method must allow the sending of content, the content
 * must exists and have some available data.
 * 
 * @return True if a content is available and can be sent.
 */
@Override
public boolean isEntityAvailable() {
  return getWrappedRequest().isEntityAvailable();
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Handles a POST call by invoking the
 * {@link #acceptRepresentation(Representation)} method. It also logs a
 * trace if there is no entity posted.
 */
@Override
public void handlePost() {
  if (!getRequest().isEntityAvailable()) {
    getLogger()
        .fine(
            "POST request received without any entity. Continuing processing.");
  }
  post(getRequest().getEntity());
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

@Override
public HttpClientCall create(Request request) {
 HttpClientCall result = null;
 try {
  result = new Hc4MethodCall(this, request.getMethod().toString(),
    request.getResourceRef().toString(), request
    .isEntityAvailable());
 }
 catch (IOException ioe) {
  getLogger().log(Level.WARNING,
    "Unable to create the HTTP client call", ioe);
 }
 return result;
}

代码示例来源:origin: org.restlet/org.restlet.ext.httpclient

/**
 * Creates a low-level HTTP client call from a high-level uniform call.
 * 
 * @param request
 *            The high-level request.
 * @return A low-level HTTP client call.
 */
@Override
public HttpClientCall create(Request request) {
  HttpClientCall result = null;
  try {
    result = new HttpMethodCall(this, request.getMethod().toString(),
        request.getResourceRef().toString(), request
            .isEntityAvailable());
  } catch (IOException ioe) {
    getLogger().log(Level.WARNING,
        "Unable to create the HTTP client call", ioe);
  }
  return result;
}

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin

@Override
public Object upload(Context context, Request request, Response response, List<FileItem> files)
  throws ResourceException
{
 // NEXUS-4151: Do not accept upload/deploy requests with media type (Content-Type) of
 // "application/x-www-form-urlencoded", since ad 1, it's wrong, ad 2, we do know
 // Jetty's Request object "eats" up it's body to parse request parameters, invoked
 // way earlier in security filters
 if (request.isEntityAvailable()) {
  MediaType mt = request.getEntity().getMediaType();
  if (mt != null && MediaType.APPLICATION_WWW_FORM.isCompatible(mt)) {
   throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Content-type of \"" + mt.toString()
     + "\" is not acceptable for uploads!");
  }
 }
 try {
  final ResourceStoreRequest req = getResourceStoreRequest(request);
  for (FileItem fileItem : files) {
   getResourceStore(request).storeItem(req, fileItem.getInputStream(), null);
  }
 }
 catch (Exception t) {
  handleException(request, response, t);
 }
 return null;
}

代码示例来源:origin: org.sonatype.nexus/nexus-rest-api

if ( request.isEntityAvailable() )

相关文章