本文整理汇总了Java中org.apache.commons.httpclient.methods.TraceMethod类的典型用法代码示例。如果您正苦于以下问题:Java TraceMethod类的具体用法?Java TraceMethod怎么用?Java TraceMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TraceMethod类属于org.apache.commons.httpclient.methods包,在下文中一共展示了TraceMethod类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCommonsHttpMethod
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
/**
* Create a Commons HttpMethodBase object for the given HTTP method
* and URI specification.
* @param httpMethod the HTTP method
* @param uri the URI
* @return the Commons HttpMethodBase object
*/
protected HttpMethodBase createCommonsHttpMethod(HttpMethod httpMethod, String uri) {
switch (httpMethod) {
case GET:
return new GetMethod(uri);
case DELETE:
return new DeleteMethod(uri);
case HEAD:
return new HeadMethod(uri);
case OPTIONS:
return new OptionsMethod(uri);
case POST:
return new PostMethod(uri);
case PUT:
return new PutMethod(uri);
case TRACE:
return new TraceMethod(uri);
case PATCH:
throw new IllegalArgumentException(
"HTTP method PATCH not available before Apache HttpComponents HttpClient 4.2");
default:
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
}
}
示例2: createResponseHandler
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
/**
* 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;
}
示例3: trace
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
public HttpResponse trace(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();
TraceMethod req = new TraceMethod(url.toString());
return submitRequest(req, rq);
}
示例4: testTraceDisabled
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
@Test
public void testTraceDisabled() throws Exception {
HttpClient httpclient = new HttpClient();
TraceMethod trace = new TraceMethod("http://localhost:" + portTraceOff + "/myservice");
httpclient.executeMethod(trace);
// TRACE shouldn't be allowed by default
assertTrue(trace.getStatusCode() == 405);
trace.releaseConnection();
}
示例5: testTraceEnabled
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
@Test
public void testTraceEnabled() throws Exception {
HttpClient httpclient = new HttpClient();
TraceMethod trace = new TraceMethod("http://localhost:" + portTraceOn + "/myservice");
httpclient.executeMethod(trace);
// TRACE is now allowed
assertTrue(trace.getStatusCode() == 200);
trace.releaseConnection();
}
示例6: testTraceDisabled
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
@Test
public void testTraceDisabled() throws Exception {
HttpClient httpclient = new HttpClient();
TraceMethod trace = new TraceMethod("http://localhost:" + portTraceOff + "/myservice");
httpclient.executeMethod(trace);
// TRACE shouldn't be allowed by default
assertTrue(trace.getStatusCode() == 405);
trace.releaseConnection();
}
示例7: testTraceEnabled
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
@Test
public void testTraceEnabled() throws Exception {
HttpClient httpclient = new HttpClient();
TraceMethod trace = new TraceMethod("http://localhost:" + portTraceOn + "/myservice");
httpclient.executeMethod(trace);
// TRACE is now allowed
assertTrue(trace.getStatusCode() == 200);
trace.releaseConnection();
}
示例8: createCommonsHttpMethod
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
/**
* Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
* @param httpMethod the HTTP method
* @param uri the URI
* @return the Commons HttpMethodBase object
*/
protected HttpMethodBase createCommonsHttpMethod(HttpMethod httpMethod, String uri) {
switch (httpMethod) {
case GET:
return new GetMethod(uri);
case DELETE:
return new DeleteMethod(uri);
case HEAD:
return new HeadMethod(uri);
case OPTIONS:
return new OptionsMethod(uri);
case POST:
return new PostMethod(uri);
case PUT:
return new PutMethod(uri);
case TRACE:
return new TraceMethod(uri);
default:
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
}
}
示例9: TraceResponseHandler
import org.apache.commons.httpclient.methods.TraceMethod; //导入依赖的package包/类
/**
* Basic constructor setting the method, and also checks if
* the request is targeted to the proxy or the underlying server.
* @param method The http method
*/
public TraceResponseHandler(TraceMethod method) {
super(method);
proxyTargeted = !method.hasBeenUsed();
}