The TRACE method is primarily used for debugging and testing purposes, and simply requests that the server echo back the request it received. This can be useful for identifying any changes to the request that is made by proxies.

The TRACE method is used to invoke a remote, application-layer loop-back of the request message. The final recipient of the request should reflect the message received back to the client as the entity-body of a 200 (OK) response. The final recipient is either the origin server or the first proxy or gateway to receive a max-Forwards value of zero (0) in the request (see section 14.31 of RFC2616).

Typical Usage

The trace method simply requires providing a URL and reading the response received. Additional headers can be added with the addRequestHeader method as with any other HttpMethod.

        TraceMethod trace = new TraceMethod("");
        // Execute the method and handle any errors.
        // Read the response body.
        String request = trace.getResponseBodyAsString();

Common Problems


RFC Section

The trace method is defined in section 9.6 of RFC2616.