geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r579674 - in /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec: HttpRequestEncoder.java HttpRequestMessage.java
Date Wed, 26 Sep 2007 14:39:46 GMT
Author: jgenender
Date: Wed Sep 26 07:39:45 2007
New Revision: 579674

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

Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestEncoder.java
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestEncoder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestEncoder.java?rev=579674&r1=579673&r2=579674&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestEncoder.java
(original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestEncoder.java
Wed Sep 26 07:39:45 2007
@@ -19,7 +19,6 @@
  */
 package org.apache.ahc.codec;
 
-import java.net.URL;
 import java.nio.charset.CharacterCodingException;
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
@@ -36,9 +35,19 @@
 import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 
+/**
+ * The Class HttpRequestEncoder. This handles the encoding of an {@link HttpRequestMessage}
into
+ * raw bytes.
+ */
 public class HttpRequestEncoder extends ProtocolEncoderAdapter {
+    
+    /** The Constant TYPES. */
     private static final Set TYPES;
+    
+    /** The Constant CRLF. */
     private static final byte[] CRLF = new byte[] {0x0D, 0x0A};
+    
+    /** The Constant POST_CONTENT_TYPE. */
     private static final String POST_CONTENT_TYPE = "application/x-www-form-urlencoded";
 
     static {
@@ -47,13 +56,29 @@
         TYPES = Collections.unmodifiableSet(types);
     }
 
+    /**
+     * Instantiates a new http request encoder.
+     */
     public HttpRequestEncoder() {
     }
 
+    /**
+     * Gets the message types for the MINA infrastructure.
+     * 
+     * @return the message types
+     */
     public Set<Class<?>> getMessageTypes() {
         return TYPES;
     }
 
+    /**
+     * Method responsible for encoding a HttpRequestMessage into raw bytes.
+     * 
+     * @param ioSession the {@link org.apache.mina.common.IoSession} representing the connection
to the server.
+     * @param object the {@link HttpRequestMessage} object
+     * @param out {@link org.apache.mina.filter.codec.ProtocolEncoderOutput} used for output
+     * @see org.apache.mina.filter.codec.ProtocolEncoder#encode(org.apache.mina.common.IoSession,
java.lang.Object, org.apache.mina.filter.codec.ProtocolEncoderOutput)
+     */
     public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out) throws
Exception {
         HttpRequestMessage msg = (HttpRequestMessage)message;
 
@@ -153,6 +178,15 @@
 
     }
 
+    /**
+     * Process header encoding.
+     * 
+     * @param msg the {@link HttpRequestMessage} message object
+     * @param buf the <code>ByteBuffer</code> in which to place the raw bytes
+     * @param encoder the character set encoder
+     * 
+     * @throws Exception if any exception occurs.
+     */
     private void processHeaders(HttpRequestMessage msg, ByteBuffer buf, CharsetEncoder encoder)
         throws Exception {
         List<NameValuePair> headers = msg.getHeaders();
@@ -167,6 +201,15 @@
         }
     }
 
+    /**
+     * Process cookies.
+     * 
+     * @param msg the msg
+     * @param buf the buf
+     * @param encoder the encoder
+     * 
+     * @throws Exception the exception
+     */
     private void processCookies(HttpRequestMessage msg, ByteBuffer buf, CharsetEncoder encoder)
         throws Exception {
         List<Cookie> cookies = msg.getCookies();

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java?rev=579674&r1=579673&r2=579674&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java
(original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpRequestMessage.java
Wed Sep 26 07:39:45 2007
@@ -27,57 +27,135 @@
 import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
 
+/**
+ * The Class HttpRequestMessage. This is an object representation of an HTTP request.
+ */
 public class HttpRequestMessage extends HttpMessage {
 
+    /** The Constant DEFAULT_REQUEST_TIMEOUT. */
     public static final int DEFAULT_REQUEST_TIMEOUT = 30000;
 
+    /** The Constant REQUEST_GET. */
     public static final String REQUEST_GET = "GET";
+    
+    /** The Constant REQUEST_POST. */
     public static final String REQUEST_POST = "POST";
+    
+    /** The Constant REQUEST_HEAD. */
     public static final String REQUEST_HEAD = "HEAD";
+    
+    /** The Constant REQUEST_OPTIONS. */
     public static final String REQUEST_OPTIONS = "OPTIONS";
+    
+    /** The Constant REQUEST_PUT. */
     public static final String REQUEST_PUT = "PUT";
+    
+    /** The Constant REQUEST_DELETE. */
     public static final String REQUEST_DELETE = "DELETE";
+    
+    /** The Constant REQUEST_TRACE. */
     public static final String REQUEST_TRACE = "TRACE";
 
+    /** The request method. */
     private String requestMethod = REQUEST_GET;
+    
+    /** The request url. */
     private URL url;
+    
+    /** The parameters. */
     private Map<String, String> parameters = new HashMap<String, String>();
+    
+    /** The user agent. */
     private String userAgent = "AsyncHttpClient 1.0";
+    
+    /** The follow redirects. */
     private boolean followRedirects = true;
+    
+    /** The timeout handle. */
     private ScheduledFuture timeoutHandle;
+    
+    /** The callback. */
     private AsyncHttpClientCallback callback;
+    
+    /** The time out. */
     private int timeOut = DEFAULT_REQUEST_TIMEOUT;
 
+    /**
+     * Instantiates a new http request message.
+     * 
+     * @param url the complete url for which the request including scheme, host, port[optional],
and query 
+     * 				(i.e. <code>http://www.example.com:8080/example.cgi?test=me</code>).
+     * @param callback the {@link org.apache.ahc.AsyncHttpClientCallback} callback class
to receive notifications when they occur.
+     */
     public HttpRequestMessage(URL url, AsyncHttpClientCallback callback) {
         this.url = url;
         this.callback = callback;
     }
 
+    /**
+     * Gets the time out.
+     * 
+     * @return the time out in milliseconds.  Defaults to {@link #DEFAULT_REQUEST_TIMEOUT}
if not set.
+     */
     public int getTimeOut() {
         return timeOut;
     }
 
+    /**
+     * Sets the time out.
+     * 
+     * @param timeOut the new time out in milliseconds. Defaults to {@link #DEFAULT_REQUEST_TIMEOUT}
if not set.
+     */
     public void setTimeOut(int timeOut) {
         this.timeOut = timeOut;
     }
 
+    /**
+     * Gets the timeout handle.
+     * 
+     * @return the timeout <code>ScheduledFuture</code> handle
+     */
     protected ScheduledFuture getTimeoutHandle() {
         return timeoutHandle;
     }
 
+    /**
+     * Sets the timeout handle.
+     * 
+     * @param timeoutHandle the new <code>ScheduledFuture</code> timeout handle
+     */
     protected void setTimeoutHandle(ScheduledFuture timeoutHandle) {
         this.timeoutHandle = timeoutHandle;
     }
 
+    /**
+     * Gets the request method.
+     * 
+     * @return the request method.  Defaults to {@link #REQUEST_GET} if not set.
+     */
     public String getRequestMethod() {
         return requestMethod;
     }
 
 
+    /**
+     * Gets the callback.
+     * 
+     * @return the {@link org.apache.ahc.AsyncHttpClientCallback} callback
+     */
     public AsyncHttpClientCallback getCallback() {
         return callback;
     }
 
+    /**
+     * Sets the request method.
+     * 
+     * @param requestMethod the new request method
+     * 
+     * @throws ProtocolException 	if the request method is not of type {@link #REQUEST_GET},
+     * 								{@link #REQUEST_POST},{@link #REQUEST_HEAD},{@link #REQUEST_OPTIONS},
+     * 								{@link #REQUEST_PUT},{@link #REQUEST_DELETE}, or {@link #REQUEST_TRACE}
+     */
     public void setRequestMethod(String requestMethod) throws ProtocolException {
         if (requestMethod.equals(REQUEST_GET)
             || requestMethod.equals(REQUEST_POST)
@@ -93,22 +171,47 @@
         throw new ProtocolException("Invalid request method type.");
     }
 
+    /**
+     * Gets the url.
+     * 
+     * @return the url
+     */
     public URL getUrl() {
         return url;
     }
 
+    /**
+     * Sets the url.
+     * 
+     * @param url the new url
+     */
     public void setUrl(URL url) {
         this.url = url;
     }
 
+    /**
+     * Gets the path part of the url.
+     * 
+     * @return the path part of the url
+     */
     public String getPath() {
         return url.getPath();
     }
 
+    /**
+     * Gets the host part of the url.
+     * 
+     * @return the host part of the url
+     */
     public String getHost(){
         return url.getHost();
     }
 
+    /**
+     * Gets the port part of the url.
+     * 
+     * @return the port part of the url
+     */
     public int getPort(){
         String scheme = url.getProtocol();
         int port = url.getPort();
@@ -123,38 +226,88 @@
         return port;
     }
 
+    /**
+     * Gets the protocol part of the url.
+     * 
+     * @return the protocol part of the url
+     */
     public String getProtocol(){
         return url.getProtocol();     
     }
 
+    /**
+     * Gets a parameter from the parameter map.
+     * 
+     * @param name the parameter name
+     * 
+     * @return the parameter value
+     */
     public String getParameter(String name) {
         return parameters.get(name);
     }
 
+    /**
+     * Gets the parameter map.
+     * 
+     * @return the parameter map
+     */
     public Map<String, String> getParameters() {
         return parameters;
     }
 
+    /**
+     * Sets the parameter map.
+     * 
+     * @param parameters the parameter map
+     */
     public void setParameters(Map<String, String> parameters) {
         this.parameters.putAll(parameters);
     }
 
+    /**
+     * Sets a single parameter.
+     * 
+     * @param name the parameter name
+     * @param value the value of parameter
+     */
     public void setParameter(String name, String value) {
         parameters.put(name, value);
     }
 
+    /**
+     * Gets the user agent string.
+     * 
+     * @return the user agent <code>String</code>
+     */
     public String getUserAgent() {
         return userAgent;
     }
 
+    /**
+     * Sets the user agent string.
+     * 
+     * @param userAgent the new user agent <code>String</code>
+     */
     public void setUserAgent(String userAgent) {
         this.userAgent = userAgent;
     }
 
+    /**
+     * Checks if the request will follow redirects (301,302 and 307 HTTP status).
+     * 
+     * @return <code>true</code>, if the request will follow redirects, <code>false</code>
if not. 
+     * 			 Defaults to <code>true</code> if not set.
+     */
     public boolean isFollowRedirects() {
         return followRedirects;
     }
 
+    /**
+     * Sets whether the request will follow redirects (301,302 and 307 HTTP status).
+     * 
+     * @param followRedirects 	the new follow redirects.  Set to <code>true</code>,
if the request 
+     * 							will follow redirects, <code>false</code> if not.
+     */
     public void setFollowRedirects(boolean followRedirects) {
         this.followRedirects = followRedirects;
     }



Mime
View raw message