Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.jetty.testing
Class HttpTester

    java.lang.Object
      org.mortbay.jetty.testing.HttpTester

    public class HttpTester

extends Object

Test support class. Assist with parsing and generating HTTP requests and responses.

          HttpTester tester = new HttpTester();

          tester.parse(
              "GET /uri HTTP/1.1\r\n"+
              "Host: fakehost\r\n"+
              "Content-Length: 10\r\n" +
              "\r\n");

          System.err.println(tester.getMethod());
          System.err.println(tester.getURI());
          System.err.println(tester.getVersion());
          System.err.println(tester.getHeader("Host"));
          System.err.println(tester.getContent());

Author:
  gregw
See Also:
  `ServletTester`

Field Summary
`protected HttpFields` | `_fields`
`protected byte[]` | `_genContent`
`protected String` | `_method`
`protected ByteArrayOutputStream2` | `_parsedContent`
`protected String` | `_reason`
`protected int` | `_status`
`protected String` | `_uri`
`protected String` | `_version`

Constructor Summary
`HttpTester()`

Method Summary
`void` | `addDateHeader(String name, long date)`
`void` | `addHeader(String name, String value)`
`void` | `addLongHeader(String name, long value)`
`void` | `addSetCookie(Cookie cookie)`
`String` | `generate()`
`String` | `getContent()`
`long` | `getDateHeader(String name)`
`String` | `getHeader(String name)`
`Enumeration` | `getHeaderNames()`
`Enumeration` | `getHeaderValues(String name)`
`long` | `getLongHeader(String name)`
`String` | `getMethod()`
`String` | `getReason()`
`int` | `getStatus()`
`String` | `getURI()`
`String` | `getVersion()`
`String` | `parse(String rawHTTP)` Parse one HTTP request or response
`void` | `removeHeader(String name)`
`void` | `reset()`
`void` | `setContent(String content)`
`void` | `setDateHeader(String name, long date)`
`void` | `setHeader(String name, String value)`
`void` | `setLongHeader(String name, long value)`
`void` | `setMethod(String method)`
`void` | `setReason(String reason)`
`void` | `setStatus(int status)`
`void` | `setURI(String uri)`
`void` | `setVersion(String version)`

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

Field Detail

### _fields

    protected HttpFields _fields

### _method

    protected String _method

### _uri

    protected String _uri

### _version

    protected String _version

### _status

    protected int _status

### _reason

    protected String _reason

### _parsedContent

    protected ByteArrayOutputStream2 _parsedContent

### _genContent

    protected byte[] _genContent

Constructor Detail

### HttpTester

    public HttpTester()

Method Detail

### reset

    public void reset()

### parse

    public String parse(String rawHTTP)
                 throws IOException

  Parse one HTTP request or response

  Parameters:
    `rawHTTP` - Raw HTTP to parse
  Returns:
    Any unparsed data in the rawHTTP (eg pipelined requests)
  Throws:
    `IOException`

### generate

    public String generate()
                    throws IOException

  Throws:
    `IOException`

### getMethod

    public String getMethod()

  Returns:
    the method

### setMethod

    public void setMethod(String method)

  Parameters:
    `method` - the method to set

### getReason

    public String getReason()

  Returns:
    the reason

### setReason

    public void setReason(String reason)

  Parameters:
    `reason` - the reason to set

### getStatus

    public int getStatus()

  Returns:
    the status

### setStatus

    public void setStatus(int status)

  Parameters:
    `status` - the status to set

### getURI

    public String getURI()

  Returns:
    the uri

### setURI

    public void setURI(String uri)

  Parameters:
    `uri` - the uri to set

### getVersion

    public String getVersion()

  Returns:
    the version

### setVersion

    public void setVersion(String version)

  Parameters:
    `version` - the version to set

### addHeader

    public void addHeader(String name,
                          String value)
                   throws IllegalArgumentException

  Parameters:
    `name` -
    `value` -
  Throws:
    `IllegalArgumentException`
  See Also:
    `HttpFields.add(java.lang.String, java.lang.String)`

### addDateHeader

    public void addDateHeader(String name,
                              long date)

  Parameters:
    `name` -
    `date` -
  See Also:
    `HttpFields.addDateField(java.lang.String, long)`

### addLongHeader

    public void addLongHeader(String name,
                              long value)

  Parameters:
    `name` -
    `value` -
  See Also:
    `HttpFields.addLongField(java.lang.String, long)`

### addSetCookie

    public void addSetCookie(Cookie cookie)

  Parameters:
    `cookie` -
  See Also:
    `HttpFields.addSetCookie(javax.servlet.http.Cookie)`

### getDateHeader

    public long getDateHeader(String name)

  Parameters:
    `name` -
  Returns:
  See Also:
    `HttpFields.getDateField(java.lang.String)`

### getHeaderNames

    public Enumeration getHeaderNames()

  Returns:
  See Also:
    `HttpFields.getFieldNames()`

### getLongHeader

    public long getLongHeader(String name)
                       throws NumberFormatException

  Parameters:
    `name` -
  Returns:
  Throws:
    `NumberFormatException`
  See Also:
    `HttpFields.getLongField(java.lang.String)`

### getHeader

    public String getHeader(String name)

  Parameters:
    `name` -
  Returns:
  See Also:
    `HttpFields.getStringField(java.lang.String)`

### getHeaderValues

    public Enumeration getHeaderValues(String name)

  Parameters:
    `name` -
  Returns:
  See Also:
    `HttpFields.getValues(java.lang.String)`

### setHeader

    public void setHeader(String name,
                          String value)

  Parameters:
    `name` -
    `value` -
  See Also:
    `HttpFields.put(java.lang.String, java.lang.String)`

### setDateHeader

    public void setDateHeader(String name,
                              long date)

  Parameters:
    `name` -
    `date` -
  See Also:
    `HttpFields.putDateField(java.lang.String, long)`

### setLongHeader

    public void setLongHeader(String name,
                              long value)

  Parameters:
    `name` -
    `value` -
  See Also:
    `HttpFields.putLongField(java.lang.String, long)`

### removeHeader

    public void removeHeader(String name)

  Parameters:
    `name` -
  See Also:
    `HttpFields.remove(java.lang.String)`

### getContent

    public String getContent()

### setContent

    public void setContent(String content)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.