Example usage for org.apache.commons.httpclient.methods TraceMethod getResponseHeaders

List of usage examples for org.apache.commons.httpclient.methods TraceMethod getResponseHeaders

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods TraceMethod getResponseHeaders.

Prototype

@Override
public Header[] getResponseHeaders() 

Source Link

Document

Returns an array of the response headers that the HTTP method currently has in the order in which they were read.

Usage

From source file:org.collectionspace.services.client.test.ServiceLayerTest.java

@Test
public void traceSupported() {
    if (logger.isDebugEnabled()) {
        logger.debug(BaseServiceTest.testBanner("traceSupported", CLASS_NAME));
    }//www .  ja  v a 2 s  . c  o  m
    String url = serviceClient.getBaseURL() + "collectionobjects";
    TraceMethod method = new TraceMethod(url);
    try {
        int statusCode = httpClient.executeMethod(method);

        if (logger.isDebugEnabled()) {
            logger.debug("traceSupported url=" + url + " status=" + statusCode);
            logger.debug("traceSupported response=" + new String(method.getResponseBody()));
            for (Header h : method.getResponseHeaders()) {
                logger.debug("traceSupported header name=" + h.getName() + " value=" + h.getValue());
            }
        }
        Assert.assertEquals(statusCode, HttpStatus.SC_METHOD_NOT_ALLOWED,
                "expected " + HttpStatus.SC_METHOD_NOT_ALLOWED);
    } catch (HttpException e) {
        logger.error("Fatal protocol violation: ", e);
    } catch (IOException e) {
        logger.error("Fatal transport error", e);
    } catch (Exception e) {
        logger.error("unknown exception ", e);
    } finally {
        // Release the connection.
        method.releaseConnection();
    }
}