## org.mortbay.jetty.client
Class HttpExchange

    java.lang.Object
      org.mortbay.jetty.client.HttpExchange

Direct Known Subclasses:
  HttpExchange.CachedExchange

    public class HttpExchange

extends Object

VERY rough start to a client API - inpired by javascript XmlHttpRequest.

Author:
  gregw, Guillaume Nodet

Nested Class Summary
`static class` `HttpExchange.CachedExchange`
`static class` `HttpExchange.ContentExchange`

Field Summary
`static int` `STATUS_COMPLETED`
`static int` `STATUS_EXPIRED`
`static int` `STATUS_PARSING_CONTENT`
`static int` `STATUS_PARSING_HEADERS`
`static int` `STATUS_SENDING_REQUEST`
`static int` `STATUS_UNKOWN`
`static int` `STATUS_WAITING_FOR_COMMIT`
`static int` `STATUS_WAITING_FOR_CONNECTION`
`static int` `STATUS_WAITING_FOR_RESPONSE`

Constructor Summary
`HttpExchange()`

Method Summary
`void` `addRequestHeader(Buffer name, Buffer value)`
`void` `addRequestHeader(String name, String value)`
`InetSocketAddress` `getAddress()`
`String` `getMethod()`
`Buffer` `getRequestContent()`
`Buffer` `getRequestContentChunk()`
`InputStream` `getRequestContentSource()`
`HttpFields` `getRequestFields()`
`Buffer` `getScheme()`
`int` `getStatus()`
`String` `getURI()`
`int` `getVersion()`
`protected void` `onConnectionFailed(Throwable ex)`
`protected void` `onException(Throwable ex)`
`protected void` `onExpire()`
`protected void` `onRequestCommitted()`
`protected void` `onRequestComplete()`
`protected void` `onResponseComplete()`
`protected void` `onResponseContent(Buffer content)`
`protected void` `onResponseHeader(Buffer name, Buffer value)`
`protected void` `onResponseHeaderComplete()`
`protected void` `onResponseStatus(Buffer version, int status, Buffer reason)`
`void` `setAddress(InetSocketAddress address)`
`void` `setMethod(String method)`
`void` `setRequestContent(Buffer requestContent)`
`void` `setRequestContentSource(InputStream in)`
`void` `setRequestContentType(String value)`
`void` `setRequestHeader(Buffer name, Buffer value)`
`void` `setRequestHeader(String name, String value)`
`void` `setScheme(Buffer scheme)`
`void` `setURI(String uri)`
`void` `setURL(String url)`
`void` `setVersion(int version)`
`void` `setVersion(String version)`
`String` `toString()`
`void` `waitForStatus(int status)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### STATUS_UNKOWN

    public static final int STATUS_UNKOWN

See Also:
  Constant Field Values

### STATUS_WAITING_FOR_CONNECTION

    public static final int STATUS_WAITING_FOR_CONNECTION

See Also:
  Constant Field Values

### STATUS_WAITING_FOR_COMMIT

    public static final int STATUS_WAITING_FOR_COMMIT

See Also:
  Constant Field Values

### STATUS_SENDING_REQUEST

    public static final int STATUS_SENDING_REQUEST

See Also:
  Constant Field Values

### STATUS_WAITING_FOR_RESPONSE

    public static final int STATUS_WAITING_FOR_RESPONSE

See Also:
  Constant Field Values

### STATUS_PARSING_HEADERS

    public static final int STATUS_PARSING_HEADERS

See Also:
  Constant Field Values

### STATUS_PARSING_CONTENT

    public static final int STATUS_PARSING_CONTENT

See Also:
  Constant Field Values

### STATUS_COMPLETED

    public static final int STATUS_COMPLETED

See Also:
  Constant Field Values

### STATUS_EXPIRED

    public static final int STATUS_EXPIRED

See Also:
  Constant Field Values

Constructor Detail

### HttpExchange

    public HttpExchange()

Method Detail

### getStatus

    public int getStatus()

### waitForStatus

    public void waitForStatus(int status)
                       throws InterruptedException

  Throws:
    `InterruptedException`

### setURL

    public void setURL(String url)

  Parameters:
    `url` -

### setAddress

    public void setAddress(InetSocketAddress address)

  Parameters:
    `address` -

### getAddress

    public InetSocketAddress getAddress()

  Returns:

### setScheme

    public void setScheme(Buffer scheme)

  Parameters:
    `scheme` -

### getScheme

    public Buffer getScheme()

  Returns:

### setVersion

    public void setVersion(int version)

  Parameters:
    `version` - as integer, 9, 10 or 11 for 0.9, 1.0 or 1.1

### setVersion

    public void setVersion(String version)

### getVersion

    public int getVersion()

  Returns:

### setMethod

    public void setMethod(String method)

  Parameters:
    `method` -

### getMethod

    public String getMethod()

  Returns:

### getURI

    public String getURI()

  Returns:

### setURI

    public void setURI(String uri)

  Parameters:
    `uri` -

### addRequestHeader

    public void addRequestHeader(String name,
                                 String value)

  Parameters:
    `name` -
    `value` -

### addRequestHeader

    public void addRequestHeader(Buffer name,
                                 Buffer value)

  Parameters:
    `name` -
    `value` -

### setRequestHeader

    public void setRequestHeader(String name,
                                 String value)

  Parameters:
    `name` -
    `value` -

### setRequestHeader

    public void setRequestHeader(Buffer name,
                                 Buffer value)

  Parameters:
    `name` -
    `value` -

### setRequestContentType

    public void setRequestContentType(String value)

  Parameters:
    `value` -

### getRequestFields

    public HttpFields getRequestFields()

  Returns:

### setRequestContent

    public void setRequestContent(Buffer requestContent)

  Parameters:
    `requestContent` -

### setRequestContentSource

    public void setRequestContentSource(InputStream in)

  Parameters:
    `requestContent` -

### getRequestContentSource

    public InputStream getRequestContentSource()

### getRequestContentChunk

    public Buffer getRequestContentChunk()
                                  throws IOException

  Throws:
    `IOException`

### getRequestContent

    public Buffer getRequestContent()

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### onRequestCommitted

    protected void onRequestCommitted()
                               throws IOException

  Throws:
    `IOException`

### onRequestComplete

    protected void onRequestComplete()
                              throws IOException

  Throws:
    `IOException`

### onResponseStatus

    protected void onResponseStatus(Buffer version,
                                    int status,
                                    Buffer reason)
                             throws IOException

  Throws:
    `IOException`

### onResponseHeader

    protected void onResponseHeader(Buffer name,
                                    Buffer value)
                             throws IOException

  Throws:
    `IOException`

### onResponseHeaderComplete

    protected void onResponseHeaderComplete()
                                     throws IOException

  Throws:
    `IOException`

### onResponseContent

    protected void onResponseContent(Buffer content)
                              throws IOException

  Throws:
    `IOException`

### onResponseComplete

    protected void onResponseComplete()
                               throws IOException

  Throws:
    `IOException`

### onConnectionFailed

    protected void onConnectionFailed(Throwable ex)

### onException

    protected void onException(Throwable ex)

### onExpire

    protected void onExpire()

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.