From faad31ce05ba2619928e1fa13ce8873b8a574f17 Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Sat, 23 Oct 2010 19:40:19 +0000 Subject: [PATCH] Fixed comments --- src/zutil/network/http/HTTPHeaderParser.java | 61 ++++++++++++-------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/src/zutil/network/http/HTTPHeaderParser.java b/src/zutil/network/http/HTTPHeaderParser.java index cf2258b..2aaa805 100644 --- a/src/zutil/network/http/HTTPHeaderParser.java +++ b/src/zutil/network/http/HTTPHeaderParser.java @@ -27,8 +27,8 @@ public class HTTPHeaderParser { /** * Parses the HTTP header information from the stream * - * @param in is the stream - * @throws IOException + * @param in is the stream + * @throws IOException */ public HTTPHeaderParser(BufferedReader in) throws IOException{ url_attr = new HashMap(); @@ -48,7 +48,7 @@ public class HTTPHeaderParser { /** * Parses the HTTP header information from an String * - * @param in is the string + * @param in is the string */ public HTTPHeaderParser(String in){ url_attr = new HashMap(); @@ -71,9 +71,9 @@ public class HTTPHeaderParser { * Parses the first header line and ads the values to * the map and returns the file name and path * - * @param header The header String - * @param map The HashMap to put the variables to - * @return The path and file name as a String + * @param header The header String + * @param map The HashMap to put the variables to + * @return The path and file name as a String */ protected void parseFirstLine(String line){ // Server Response @@ -106,8 +106,20 @@ public class HTTPHeaderParser { * Parses a String with variables from a get or post * that was sent from a client and puts the data into a HashMap * - * @param header is the String containing all the attributes - * @param map is the HashMap to put all the values into + * @param attributes is the String containing all the attributes + */ + public static HashMap parseUrlAttributes( String attributes ){ + HashMap map = new HashMap(); + parseUrlAttributes(attributes, map); + return map; + } + + /** + * Parses a String with variables from a get or post + * that was sent from a client and puts the data into a HashMap + * + * @param attributes is the String containing all the attributes + * @param map is the HashMap to put all the values into */ public static void parseUrlAttributes(String attributes, HashMap map){ String[] tmp; @@ -124,7 +136,7 @@ public class HTTPHeaderParser { /** * Parses the rest of the header * - * @param line is the next line in the header + * @param line is the next line in the header */ protected void parseLine(String line){ String[] data = colonPattern.split( line, 2 ); @@ -137,7 +149,7 @@ public class HTTPHeaderParser { * Parses the attribute "Cookie" and returns a HashMap * with the values * - * @return a HashMap with cookie values + * @return a HashMap with cookie values */ protected void parseCookies(){ if( headers.containsKey("COOKIE") ){ @@ -153,46 +165,49 @@ public class HTTPHeaderParser { } /** - * @return the HTTP message type( ex. GET,POST...) + * @return the HTTP message type( ex. GET,POST...) */ public String getRequestType(){ return type; } /** - * @return the HTTP version of this header + * @return the HTTP version of this header */ public float getHTTPVersion(){ return version; } /** - * @return the HTTP Return Code from a Server + * @return the HTTP Return Code from a Server */ public float getHTTPCode(){ return httpCode; } /** - * @return the URL that the client sent the server + * @return the URL that the client sent the server */ public String getRequestURL(){ return url; } /** - * Returns the URL attribute value of the given name, - * returns null if there is no such attribute + * Returns the URL attribute value of the given name. + * + * returns null if there is no such attribute */ public String getURLAttribute(String name){ return url_attr.get( name ); } /** - * Returns the HTTP attribute value of the given name, - * returns null if there is no such attribute + * Returns the HTTP attribute value of the given name. + * + * returns null if there is no such attribute */ public String getHeader(String name){ return headers.get( name.toUpperCase() ); } /** - * Returns the cookie value of the given name, - * returns null if there is no such attribute + * Returns the cookie value of the given name. + * + * returns null if there is no such attribute */ public String getCookie(String name){ return cookies.get( name ); @@ -200,19 +215,19 @@ public class HTTPHeaderParser { /** - * @return a map of the parsed cookies + * @return a map of the parsed cookies */ public HashMap getCookies(){ return cookies; } /** - * @return a map of the parsed URL attributes + * @return a map of the parsed URL attributes */ public HashMap getURLAttributes(){ return url_attr; } /** - * @return a map of the parsed headers + * @return a map of the parsed headers */ public HashMap getHeaders(){ return headers;