HttpClient - Trace Method
Author: Adrian Sutton

##### Overview

- Features
- News
- Status
- Download
- Wiki
- User Guide
  - Authentication Guide
  - Character Encodings
  - Cookies
  - Exception Handling
  - Logging Guide
  - Methods
  - Optimization Guide
  - Preference Architecture
  - Redirects Handling
  - Sample Code
  - SSL Guide
  - Threading
  - Trouble Shooting
  - Tutorial
- Developer Guide

##### Project Documentation

- About
- Project Info
- Project Reports
- Development Process

##### Legend

- External Link
- Opens in a new window

## Introduction

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("http://jakarata.apache.org");
            // Execute the method and handle any errors.
            ...
            // Read the response body.
            String request = trace.getResponseBodyAsString();
            trace.releaseConnection();

## Common Problems

None.

## RFC Section

The trace method is defined in section 9.6 of RFC2616.