org.apache.commons.httpclient

Class StatusLine


public class StatusLine
extends Object

Represents a Status-Line as returned from a HTTP server. RFC2616 states the following regarding the Status-Line:
 6.1 Status-Line

  The first line of a Response message is the Status-Line, consisting
  of the protocol version followed by a numeric status code and its
  associated textual phrase, with each element separated by SP
  characters. No CR or LF is allowed except in the final CRLF sequence.

      Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
 

This class is immutable and is inherently thread safe.

Since:
2.0
See Also:
HttpStatus

Constructor Summary

StatusLine(String statusLine)
Default constructor.

Method Summary

String
getHttpVersion()
String
getReasonPhrase()
int
getStatusCode()
static boolean
startsWithHTTP(String s)
Tests if the string starts with 'HTTP' signature.
String
toString()
Return a string representation of this object.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

StatusLine

public StatusLine(String statusLine)
            throws HttpException
Default constructor.
Parameters:
statusLine - the status line returned from the HTTP server
Throws:
HttpException - if the status line is invalid
Usages and Demos :

View More Examples of StatusLine(String statusLine)
   1:             SimpleResponse response = new SimpleResponse(
   2:                     new StatusLine(line),
   3:                     HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
   4:                     this.in);
   5:             return response;

View Full Code Here
   1:         }
   2:         this.httpStatus = new StatusLine(statusLine);
   3:         
   4:         ByteArrayOutputStream baos =
   5:             new ByteArrayOutputStream(statusBytes.length + 4 * 1024);

View Full Code Here

Method Details

getHttpVersion

public final String getHttpVersion()
Returns:
the HTTP-Version
Usages and Demos :

View More Examples of getHttpVersion()
   1: import org.apache.commons.httpclient.NameValuePair;
   2: import org.apache.commons.httpclient.StatusLine;
   3: 
   4:         ...
   5:     public SimpleResponse(
   6:             final StatusLine statusline, 
   7:             final Header[] headers, 
   8:         ...
   9:         }
  10:         setStatusLine(HttpVersion.parse(statusline.getHttpVersion()),
  11:                 statusline.getStatusCode(), statusline.getReasonPhrase());

View Full Code Here

getReasonPhrase

public final String getReasonPhrase()
Returns:
the Reason-Phrase
Usages and Demos :

View More Examples of getReasonPhrase()
   1: import org.apache.commons.httpclient.NameValuePair;
   2: import org.apache.commons.httpclient.StatusLine;
   3: 
   4:         ...
   5:     public SimpleResponse(
   6:             final StatusLine statusline, 
   7:             final Header[] headers, 
   8:         ...
   9:         setStatusLine(HttpVersion.parse(statusline.getHttpVersion()),
  10:                 statusline.getStatusCode(), statusline.getReasonPhrase());
  11:         setHeaders(headers);

View Full Code Here

getStatusCode

public final int getStatusCode()
Returns:
the Status-Code
Usages and Demos :

View More Examples of getStatusCode()
   1: import org.apache.commons.httpclient.NameValuePair;
   2: import org.apache.commons.httpclient.StatusLine;
   3: 
   4:         ...
   5:     public SimpleResponse(
   6:             final StatusLine statusline, 
   7:             final Header[] headers, 
   8:         ...
   9:         setStatusLine(HttpVersion.parse(statusline.getHttpVersion()),
  10:                 statusline.getStatusCode(), statusline.getReasonPhrase());
  11:         setHeaders(headers);

View Full Code Here

startsWithHTTP

public static boolean startsWithHTTP(String s)
Tests if the string starts with 'HTTP' signature.
Parameters:
s - string to test
Returns:
true if the line starts with 'HTTP' signature, false otherwise.

toString

public final String toString()
Return a string representation of this object.
Overrides:
toString in interface Object
Returns:
a string represenation of this object.