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

x33g5p2x  于2022-01-28 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(116)

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

Request.setMethod介绍

[英]Sets the method called.
[中]设置调用的方法。

代码示例

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

/**
 * Sets the method called.
 * 
 * @param method
 *            The method called.
 */
@Override
public void setMethod(Method method) {
  getWrappedRequest().setMethod(method);
}

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

/**
 * Sets the method called.
 * 
 * @param method
 *            The method called.
 * @see Request#setMethod(Method)
 */
public void setMethod(Method method) {
  getRequest().setMethod(method);
}

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

@Override
public void setHttpMethod(String name) {
  getRequest().setMethod(Method.valueOf(name));
}

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

/**
 * Updates the request method based on specific header.
 * 
 * @param request
 *            The request to update.
 */
@SuppressWarnings("unchecked")
private void processHeaders(Request request) {
  final TunnelService tunnelService = getTunnelService();
  if (tunnelService.isMethodTunnel()) {
    // get the headers
    Series<Header> extraHeaders = (Series<Header>) request
        .getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS);
    if (extraHeaders != null) {
      // look for the new value of the method
      final String newMethodValue = extraHeaders.getFirstValue(
          getTunnelService().getMethodHeader(), true);
      if (newMethodValue != null
          && newMethodValue.trim().length() > 0) {
        // set the current method to the new method
        request.setMethod(Method.valueOf(newMethodValue));
      }
    }
  }
}

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

/**
 * Handles the call by cloning the prototype request, setting the method and
 * entity.
 * 
 * @param method
 *            The request method to use.
 * @param entity
 *            The request entity to set.
 * @param clientInfo
 *            The client preferences.
 * @return The optional response entity.
 */
protected Representation handle(Method method, Representation entity,
    ClientInfo clientInfo) {
  // Prepare the request by cloning the prototype request
  Request request = createRequest();
  request.setMethod(method);
  request.setEntity(entity);
  request.setClientInfo(clientInfo);
  // Actually handle the call
  Response response = handleOutbound(request);
  return handleInbound(response);
}

代码示例来源:origin: apache/attic-polygene-java

request.setMethod( org.restlet.data.Method.POST );
response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY );
result( formForMethod( interactionMethod ) );

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server

request.setMethod( org.restlet.data.Method.POST );
response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY );
result( formForMethod( interactionMethod ) );

代码示例来源:origin: org.qi4j.library/org.qi4j.library.rest-server

request.setMethod( org.restlet.data.Method.POST );
response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY );
result( formForMethod( interactionMethod ) );

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

@Override
protected int beforeHandle(Request request, Response response) {
  Cookie cookie = request.getCookies().getFirst("Credentials");
  if (cookie != null) {
    // Extract the challenge response from the cookie
    String[] credentials = cookie.getValue().split("=");
    if (credentials.length == 2) {
      String identifier = credentials[0];
      String secret = credentials[1];
      request.setChallengeResponse(new ChallengeResponse(
          ChallengeScheme.HTTP_COOKIE, identifier, secret));
    }
  } else if (Method.POST.equals(request.getMethod())
      && request.getResourceRef().getQueryAsForm().getFirst("login") != null) {
    // Intercepting a login form
    Form credentials = new Form(request.getEntity());
    String identifier = credentials.getFirstValue("identifier");
    String secret = credentials.getFirstValue("secret");
    request.setChallengeResponse(new ChallengeResponse(
        ChallengeScheme.HTTP_COOKIE, identifier, secret));
    // Continue call processing to return the target representation if
    // authentication is successful or a new login page
    request.setMethod(Method.GET);
  }
  return super.beforeHandle(request, response);
}

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

request.setMethod(method);
request.setClientInfo(clientInfo);

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

@Override
protected int beforeHandle(Request request, Response response) {
  Cookie cookie = request.getCookies().getFirst("Credentials");
  if (cookie != null) {
    // Extract the challenge response from the cookie
    String[] credentials = cookie.getValue().split("=");
    if (credentials.length == 2) {
      String identifier = credentials[0];
      String secret = credentials[1];
      request.setChallengeResponse(new ChallengeResponse(
          ChallengeScheme.HTTP_COOKIE, identifier, secret));
    }
  } else if (Method.POST.equals(request.getMethod())
      && request.getResourceRef().getQueryAsForm().getFirst("login") != null) {
    // Intercepting a login form
    Form credentials = new Form(request.getEntity());
    String identifier = credentials.getFirstValue("identifier");
    String secret = credentials.getFirstValue("secret");
    request.setChallengeResponse(new ChallengeResponse(
        ChallengeScheme.HTTP_COOKIE, identifier, secret));
    // Continue call processing to return the target representation if
    // authentication is successful or a new login page
    request.setMethod(Method.GET);
  }
  return super.beforeHandle(request, response);
}

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

/**
 * Unit test for virtual hosts.
 * 
 * @throws Exception
 */
public void testVirtualHost() throws Exception {
  // Instantiate our Restlet component
  MailServerComponent component = new MailServerComponent();
  // Prepare a mock HTTP call
  Request request = new Request();
  request.setMethod(Method.GET);
  request.setResourceRef("http://www.rmep.org/accounts/");
  request.setHostRef("http://www.rmep.org");
  Response response = new Response(request);
  response.getServerInfo().setAddress("1.2.3.10");
  response.getServerInfo().setPort(80);
  component.handle(request, response);
  // Test if response was successful
  assertTrue(response.getStatus().isSuccess());
}

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

request.setMethod(annotationInfo.getRestletMethod());

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

request.setMethod(annotationInfo.getRestletMethod());

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

.getStatus())) {
request.setMethod(Method.GET);
request.setEntity(null);
doRedirection = true;

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

&& (Method.POST.equals(method) || Method.OPTIONS
      .equals(tunnelledMethod))) {
request.setMethod(tunnelledMethod);
query.removeFirst(tunnelService.getMethodParameter());
queryModified = true;

相关文章