Fixed comments
This commit is contained in:
parent
b5f161f7f1
commit
faad31ce05
1 changed files with 38 additions and 23 deletions
|
|
@ -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<String, String>();
|
||||
|
|
@ -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<String, String>();
|
||||
|
|
@ -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<String, String> parseUrlAttributes( String attributes ){
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
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<String, String> 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<String, String> getCookies(){
|
||||
return cookies;
|
||||
}
|
||||
/**
|
||||
* @return a map of the parsed URL attributes
|
||||
* @return a map of the parsed URL attributes
|
||||
*/
|
||||
public HashMap<String, String> getURLAttributes(){
|
||||
return url_attr;
|
||||
}
|
||||
/**
|
||||
* @return a map of the parsed headers
|
||||
* @return a map of the parsed headers
|
||||
*/
|
||||
public HashMap<String, String> getHeaders(){
|
||||
return headers;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue