geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r579685 - in /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec: HttpResponseDecoder.java HttpResponseMessage.java
Date Wed, 26 Sep 2007 15:03:26 GMT
Author: jgenender
Date: Wed Sep 26 08:03:25 2007
New Revision: 579685

URL: http://svn.apache.org/viewvc?rev=579685&view=rev
Log:
More javadoc

Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseMessage.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java?rev=579685&r1=579684&r2=579685&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java
(original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java
Wed Sep 26 08:03:25 2007
@@ -25,11 +25,26 @@
 import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
+/**
+ * The Class HttpResponseDecoder. This handles the decoding of raw bytes into a
+ * {@link HttpResponseMessage} object.
+ */
 public class HttpResponseDecoder extends CumulativeProtocolDecoder {
 
-
+    /** The http decoder. */
     private HttpDecoder httpDecoder = new HttpDecoder();
 
+    /**
+     * Decodes the raw HTTP response from a server into a {@link HttpResponseMessage} object.
+     * 
+     * @param ioSession the {@link org.apache.mina.common.IoSession} representing the connection
to the server.
+     * @param in the <code>ByteBuffer</code> that contains the raw bytes from
the server
+     * @param out {@link org.apache.mina.filter.codec.ProtocolDecoderOutput} used for output
+     * 
+     * @return <code>true</code> if it can read all of the data, or <code>false</code>
if not.  A false tells the API to fetch more data.
+     * 
+     * @see org.apache.mina.filter.codec.CumulativeProtocolDecoder#doDecode(org.apache.mina.common.IoSession,
org.apache.mina.common.ByteBuffer, org.apache.mina.filter.codec.ProtocolDecoderOutput)
+     */
     protected boolean doDecode(IoSession ioSession, ByteBuffer in, ProtocolDecoderOutput
out)
         throws Exception {
 
@@ -112,6 +127,16 @@
         }
     }
 
+    /**
+     * Reads the headers and processes them as header objects in the {@link HttpResponseMessage}
object.
+     * 
+     * @param response the {@link HttpResponseMessage} response object
+     * @param in the <code>ByteBuffer</code> that contains the raw bytes from
the server
+     * 
+     * @return <code>true</code> if it can read all of the data, or <code>false</code>
if not.
+     * 
+     * @throws Exception if any exception occurs
+     */
     private boolean processHeaders(HttpResponseMessage response, ByteBuffer in) throws Exception
{
         if (!findHeaders(response, in)) {
             return false;
@@ -121,6 +146,17 @@
         return true;
     }
 
+    /**
+     * Reads the footers and processes them as header objects in the {@link HttpResponseMessage}

+     * object.  This is only used in chunked transcoding.
+     * 
+     * @param response the {@link HttpResponseMessage} response object
+     * @param in the <code>ByteBuffer</code> that contains the raw bytes from
the server
+     * 
+     * @return <code>true</code> if it can read all of the data, or <code>false</code>
if not.
+     * 
+     * @throws Exception if any exception occurs
+     */
     private boolean processFooters(HttpResponseMessage response, ByteBuffer in) throws Exception
{
         if (!findHeaders(response, in)) {
             return false;
@@ -130,6 +166,16 @@
         return true;
     }
 
+    /**
+     * Decodes the raw headers/footers.
+     * 
+     * @param response the {@link HttpResponseMessage} response object
+     * @param in the <code>ByteBuffer</code> that contains the raw bytes from
the server
+     * 
+     * @return <code>true</code> if it can read all of the data, or <code>false</code>
if not.
+     * 
+     * @throws Exception if any exception occurs
+     */
     private boolean findHeaders(HttpResponseMessage response, ByteBuffer in) throws Exception
{
         //Read the headers and process them
         while (true) {
@@ -150,6 +196,16 @@
         return true;
     }
 
+    /**
+     * Process and read the content.
+     * 
+     * @param response the {@link HttpResponseMessage} response object
+     * @param in the <code>ByteBuffer</code> that contains the raw bytes from
the server
+     * 
+     * @return <code>true</code> if it can read all of the data, or <code>false</code>
if not.
+     * 
+     * @throws Exception if any exception occurs
+     */
     private boolean processContent(HttpResponseMessage response, ByteBuffer in) throws Exception
{
         if (response.isChunked()) {
             while (true) {
@@ -200,6 +256,16 @@
         return true;
     }
 
+    /**
+     * Process  and read the status header.
+     * 
+     * @param response the {@link HttpResponseMessage} response object
+     * @param in the <code>ByteBuffer</code> that contains the raw bytes from
the server
+     * 
+     * @return <code>true</code> if it can read all of the data, or <code>false</code>
if not.
+     * 
+     * @throws Exception if any exception occurs
+     */
     private boolean processStatus(HttpResponseMessage response, ByteBuffer in) throws Exception
{
         //Read the status header
         String header = httpDecoder.decodeLine(in);

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseMessage.java?rev=579685&r1=579684&r2=579685&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseMessage.java
(original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseMessage.java
Wed Sep 26 08:03:25 2007
@@ -19,90 +19,200 @@
  */
 package org.apache.ahc.codec;
 
+/**
+ * The Class HttpResponseMessage. This is an object representation of an HTTP response.
+ */
 public class HttpResponseMessage extends HttpMessage {
 
+    /** The Constant EXPECTED_NOT_READ. */
     static final int EXPECTED_NOT_READ = -1;
 
+    /** The Constant STATE_START. */
     static final int STATE_START = 0;
+    
+    /** The Constant STATE_STATUS_CONTINUE. */
     static final int STATE_STATUS_CONTINUE = 1;
+    
+    /** The Constant STATE_STATUS_READ. */
     static final int STATE_STATUS_READ = 2;
+    
+    /** The Constant STATE_HEADERS_READ. */
     static final int STATE_HEADERS_READ = 3;
+    
+    /** The Constant STATE_CONTENT_READ. */
     static final int STATE_CONTENT_READ = 4;
+    
+    /** The Constant STATE_FOOTERS_READ. */
     static final int STATE_FOOTERS_READ = 5;
+    
+    /** The Constant STATE_FINISHED. */
     static final int STATE_FINISHED = 6;
 
+    /** The status code. */
     private int statusCode;
+    
+    /** The status message. */
     private String statusMessage;
+    
+    /** The connection. */
     private String connection;
 
+    /** The chunked. */
     private boolean chunked;
+    
+    /** The expected to read. */
     private int expectedToRead = -1;
+    
+    /** The state. */
     private int state = STATE_START;
+    
+    /** The location. */
     private String location;
 
+    /** The attachment. */
     private Object attachment;
 
+    /**
+     * Gets the HTTP status code.
+     * 
+     * @return the HTTP status code
+     */
     public int getStatusCode() {
         return statusCode;
     }
 
+    /**
+     * Sets the HTTP status code.
+     * 
+     * @param statusCode the new HTTP status code
+     */
     public void setStatusCode(int statusCode) {
         this.statusCode = statusCode;
     }
 
+    /**
+     * Gets the HTTP status message.
+     * 
+     * @return the HTTP status message
+     */
     public String getStatusMessage() {
         return statusMessage;
     }
 
+    /**
+     * Sets the HTTP status message.
+     * 
+     * @param statusMessage the new HTTP status message
+     */
     public void setStatusMessage(String statusMessage) {
         this.statusMessage = statusMessage;
     }
 
+    /**
+     * Checks if the response is transcoded as chunked.
+     * 
+     * @return <code>true</code> if the transcoding is chunked
+     */
     boolean isChunked() {
         return chunked;
     }
 
+    /**
+     * Flags the response transcoding chunked.
+     * 
+     * @param chunked <code>true</code> if the transcoding is chunked
+     */
     void setChunked(boolean chunked) {
         this.chunked = chunked;
     }
 
+    /**
+     * Gets the expected number of bytes to read.  Used during decoding chunked transcoding.
+     * 
+     * @return the expected to read
+     */
     int getExpectedToRead() {
         return expectedToRead;
     }
 
+    /**
+     * Sets the expected number of bytes to read. Used during decoding chunked transcoding.
+     * 
+     * @param expectedToRead the new expected number of bytes to read
+     */
     void setExpectedToRead(int expectedToRead) {
         this.expectedToRead = expectedToRead;
     }
 
+    /**
+     * Gets the state of the response during decoding.
+     * 
+     * @return the state
+     */
     int getState() {
         return state;
     }
 
+    /**
+     * Sets the state of the response during decoding.
+     * 
+     * @param state the new state
+     */
     void setState(int state) {
         this.state = state;
     }
 
+    /**
+     * Gets the location that is typically set on redirects.
+     * 
+     * @return the location or <code>null</code> if one does not exist.
+     */
     public String getLocation() {
         return location;
     }
 
+    /**
+     * Sets the location that is typically set on redirects.
+     * 
+     * @param location the new location
+     */
     public void setLocation(String location) {
         this.location = location;
     }
 
+    /**
+     * Gets the <code>Connection</code> value from an HTTP header.
+     * 
+     * @return the connection
+     */
     public String getConnection() {
         return connection;
     }
 
+    /**
+     * Sets the <code>Connection</code> value from an HTTP header.
+     * 
+     * @param connection the new connection
+     */
     public void setConnection(String connection) {
         this.connection = connection;
     }
 
 
+    /**
+     * Gets the attachment.
+     * 
+     * @return the attachment
+     */
     public Object getAttachment() {
         return attachment;
     }
 
+    /**
+     * Sets the attachment.
+     * 
+     * @param attachment the new attachment
+     */
     public void setAttachment(Object attachment) {
         this.attachment = attachment;
     }



Mime
View raw message