|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.groboclown.util.http.v1.SimpleHttpGet
This class is used to replace the HTTPConnection. It has several improvements:
Field Summary | |
private static int |
CHUNKED
|
private static int |
DEFAULT_HTTP_PORT
|
private static String |
HTTP1_0
|
private static String |
HTTP1_1
|
private Socket |
m_connection
|
private int |
m_contentLength
|
private boolean |
m_isOpen
|
protected boolean |
m_isProxy
|
private int |
m_messageFormat
|
private boolean |
m_persist
|
protected String |
m_serverName
|
protected int |
m_serverPort
|
private InputStream |
m_socketIn
|
private Writer |
m_socketOut
|
private static int |
PLAIN
|
private static int |
UNKNOWN_FORMAT
|
private static int |
UNTILCLOSED
|
Constructor Summary | |
SimpleHttpGet(String serverName)
Constructor based on a server, through a non-proxy connection on port 80. |
|
SimpleHttpGet(String serverName,
int serverPort)
Constructor based on a server with a non-default port. |
|
SimpleHttpGet(String serverName,
int serverPort,
boolean isProxy)
Constructor based on a connection to the given server with the given port number, which may be a proxy connection if isProxy is true . |
Method Summary | |
static void |
addHeader(Hashtable headers,
String n,
String v)
Adds a header entry to the hashtable, creating an array entry if an entry already exists. |
static void |
addUniqueHeader(Hashtable headers,
String n,
String v)
Adds a header entry to the given hashtable only if an entry for that name does not already exist. |
protected void |
appendHeader(StringBuffer sb,
String name,
String value)
|
protected void |
buildHeaders(Hashtable headers,
String message)
|
void |
close()
Perform an absolute close on the connection. |
void |
connect()
|
protected void |
finalize()
|
protected String |
generateRequest(String type,
URL url,
Hashtable headers,
String message)
|
protected void |
getResponse(HttpResponseMessageImpl hrm)
This must be accessed only in a synchronized block. |
byte[] |
getURLMessage(URL url)
Sends a request of the given URL, and returns the server's message. |
IHttpResponseMessage |
getURLResponse(URL url)
Returns all the response data sent back by the server. |
IHttpResponseMessage |
getURLResponse(URL url,
String method,
Hashtable headers,
String messageData)
Returns all the response data sent back by the server. |
boolean |
isConnectionOpen()
Checks if the connection to the server is open. |
static void |
main(String[] args)
|
protected void |
processHead(HttpResponseMessageImpl hrm,
StringBuffer linebuffer)
|
protected void |
processStatus(HttpResponseMessageImpl hrm,
StringBuffer statusline)
|
protected void |
receiveHead(HttpResponseMessageImpl hrm)
This must be accessed only in a synchronized block. |
protected byte[] |
receiveMessage(HttpResponseMessageImpl hrm)
|
protected void |
sendRequest(String requestMessage)
|
Methods inherited from class java.lang.Object |
|
Field Detail |
protected String m_serverName
protected int m_serverPort
protected boolean m_isProxy
private static final String HTTP1_1
private static final String HTTP1_0
private static final int PLAIN
private static final int CHUNKED
private static final int UNTILCLOSED
private static final int UNKNOWN_FORMAT
private static final int DEFAULT_HTTP_PORT
private Socket m_connection
private boolean m_isOpen
private Writer m_socketOut
private InputStream m_socketIn
private boolean m_persist
private int m_messageFormat
private int m_contentLength
Constructor Detail |
public SimpleHttpGet(String serverName) throws IOException
public SimpleHttpGet(String serverName, int serverPort) throws IOException
public SimpleHttpGet(String serverName, int serverPort, boolean isProxy) throws IOException
isProxy
is true
.Method Detail |
public static void main(String[] args) throws Exception
public boolean isConnectionOpen()
public void connect() throws IOException
public IHttpResponseMessage getURLResponse(URL url) throws IOException
public IHttpResponseMessage getURLResponse(URL url, String method, Hashtable headers, String messageData) throws IOException
public byte[] getURLMessage(URL url) throws IOException
public void close()
public static void addUniqueHeader(Hashtable headers, String n, String v)
public static void addHeader(Hashtable headers, String n, String v)
protected void sendRequest(String requestMessage) throws IOException
protected void getResponse(HttpResponseMessageImpl hrm) throws IOException
protected String generateRequest(String type, URL url, Hashtable headers, String message) throws IOException
protected void appendHeader(StringBuffer sb, String name, String value)
protected void buildHeaders(Hashtable headers, String message)
protected void receiveHead(HttpResponseMessageImpl hrm) throws IOException
protected void processStatus(HttpResponseMessageImpl hrm, StringBuffer statusline) throws IOException
protected void processHead(HttpResponseMessageImpl hrm, StringBuffer linebuffer) throws IOException
protected byte[] receiveMessage(HttpResponseMessageImpl hrm) throws IOException
protected void finalize() throws Throwable
finalize
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |