/** * Sets the method called. * * @param method * The method called. */ @Override public void setMethod(Method method) { getWrappedRequest().setMethod(method); }
/** * Sets the method called. * * @param method * The method called. * @see Request#setMethod(Method) */ public void setMethod(Method method) { getRequest().setMethod(method); }
@Override public void setHttpMethod(String name) { getRequest().setMethod(Method.valueOf(name)); }
/** * 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)); } } } }
/** * 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); }
request.setMethod( org.restlet.data.Method.POST ); response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY ); result( formForMethod( interactionMethod ) );
request.setMethod( org.restlet.data.Method.POST ); response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY ); result( formForMethod( interactionMethod ) );
request.setMethod( org.restlet.data.Method.POST ); response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY ); result( formForMethod( interactionMethod ) );
@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); }
request.setMethod(method); request.setClientInfo(clientInfo);
@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); }
/** * 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()); }
request.setMethod(annotationInfo.getRestletMethod());
request.setMethod(annotationInfo.getRestletMethod());
.getStatus())) { request.setMethod(Method.GET); request.setEntity(null); doRedirection = true;
&& (Method.POST.equals(method) || Method.OPTIONS .equals(tunnelledMethod))) { request.setMethod(tunnelledMethod); query.removeFirst(tunnelService.getMethodParameter()); queryModified = true;