org.apache.commons.httpclient.methods.OptionsMethod Java Examples
The following examples show how to use
org.apache.commons.httpclient.methods.OptionsMethod.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PublicApiHttpClient.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public HttpResponse options(final RequestContext rq, Binding cmisBinding, String version, String cmisOperation) throws IOException { RestApiEndpoint endpoint = new RestApiEndpoint(rq.getNetworkId(), cmisBinding, version, cmisOperation, null); String url = endpoint.getUrl(); OptionsMethod req = new OptionsMethod(url.toString()); return submitRequest(req, rq); }
Example #2
Source File: ResponseHandlerFactory.java From development with Apache License 2.0 | 5 votes |
/** * Checks the method being received and created a * suitable ResponseHandler for this method. * * @param method Method to handle * @return The handler for this response * @throws MethodNotAllowedException If no method could be choose this exception is thrown */ public static ResponseHandler createResponseHandler(HttpMethod method) throws MethodNotAllowedException { if (!AllowedMethodHandler.methodAllowed(method)) { throw new MethodNotAllowedException("The method " + method.getName() + " is not in the AllowedHeaderHandler's list of allowed methods.", AllowedMethodHandler.getAllowHeader()); } ResponseHandler handler = null; if (method.getName().equals("OPTIONS")) { handler = new OptionsResponseHandler((OptionsMethod) method); } else if (method.getName().equals("GET")) { handler = new GetResponseHandler((GetMethod) method); } else if (method.getName().equals("HEAD")) { handler = new HeadResponseHandler((HeadMethod) method); } else if (method.getName().equals("POST")) { handler = new PostResponseHandler((PostMethod) method); } else if (method.getName().equals("PUT")) { handler = new PutResponseHandler((PutMethod) method); } else if (method.getName().equals("DELETE")) { handler = new DeleteResponseHandler((DeleteMethod) method); } else if (method.getName().equals("TRACE")) { handler = new TraceResponseHandler((TraceMethod) method); } else { throw new MethodNotAllowedException("The method " + method.getName() + " was allowed by the AllowedMethodHandler, not by the factory.", handledMethods); } return handler; }
Example #3
Source File: ResponseFilter.java From flex-blazeds with Apache License 2.0 | 4 votes |
protected void setupResponse(ProxyContext context) { String method = context.getMethod(); HttpMethodBase httpMethod = context.getHttpMethod(); if (MessageIOConstants.METHOD_POST.equals(method)) { writeResponse(context); } else if (ProxyConstants.METHOD_GET.equals(method)) { writeResponse(context); } else if (ProxyConstants.METHOD_OPTIONS.equals(method)) { OptionsMethod optionsMethod = (OptionsMethod)httpMethod; Enumeration options = optionsMethod.getAllowedMethods(); if (options != null) { List ops = new ArrayList(); while (options.hasMoreElements()) { Object option = options.nextElement(); ops.add(option); } Object[] o = ops.toArray(); context.setResponse(o); } } else if (ProxyConstants.METHOD_TRACE.equals(method)) { writeResponse(context); } else if (ProxyConstants.METHOD_DELETE.equals(method)) { writeResponse(context); } else if (ProxyConstants.METHOD_HEAD.equals(method)) { context.setResponse(context.getResponseHeaders()); } else if (ProxyConstants.METHOD_PUT.equals(method)) { writeResponse(context); } }
Example #4
Source File: OptionsResponseHandler.java From development with Apache License 2.0 | 2 votes |
/** * Constructor checking if we should handle the Allow header * ourself or respond with the backing servers header. * * @param method The method for this response */ public OptionsResponseHandler(OptionsMethod method) { super(method); useOwnAllow = !method.hasBeenUsed(); }