public class HttpEasyReader
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HttpEasyReader.Family
An enumeration representing the class of an http response status code.
|
| Constructor and Description |
|---|
HttpEasyReader(java.net.HttpURLConnection connection,
HttpEasy request)
Create new HttpEasyReader.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
asString() |
java.io.File |
downloadFile(java.lang.String saveDir)
Download a file from the response.
|
java.net.HttpURLConnection |
getConnection()
Returns the underlying connection object in the event that the
exposed methods don't provide the information you are after.
|
java.lang.String |
getHeaderField(java.lang.String name)
Response header field.
|
JsonReader |
getJsonReader() |
int |
getResponseCode()
Gets the status code from an HTTP response message, see
HttpURLConnection.getResponseCode(). |
HttpEasyReader.Family |
getResponseCodeFamily()
Gets the family of the status code from an HTTP response message, see
HttpEasyReader.Family. |
XmlReader |
getXmlReader() |
static java.lang.String |
parseForAttribute(java.lang.String attribute,
java.lang.String parseString)
Parses a string looking for a attribute-value pair, and returns the value.
|
public HttpEasyReader(java.net.HttpURLConnection connection,
HttpEasy request)
throws java.io.IOException
connection - HttpURLConnectionrequest - Request that is creating this readerorg.apache.http.client.HttpResponseException - if request failedjava.io.IOExceptionpublic java.net.HttpURLConnection getConnection()
HttpURLConnectionpublic int getResponseCode()
throws java.io.IOException
HttpURLConnection.getResponseCode().java.io.IOExceptionpublic HttpEasyReader.Family getResponseCodeFamily() throws java.io.IOException
HttpEasyReader.Family.java.io.IOExceptionpublic java.lang.String asString()
throws java.io.IOException
java.io.IOException - If unable to read the responsepublic JsonReader getJsonReader() throws java.io.IOException
java.io.IOException - If unable to read the responsepublic XmlReader getXmlReader() throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXExceptionjavax.xml.parsers.ParserConfigurationExceptionjava.io.IOException - If unable to read the responsepublic java.io.File downloadFile(java.lang.String saveDir)
throws java.io.IOException
saveDir - Location to place the file, the file name is gotten from the response headersjava.io.IOException - If unable to write the filepublic static java.lang.String parseForAttribute(java.lang.String attribute,
java.lang.String parseString)
String parseString = "Content-Disposition: filename=\"bob\" name=\"jack\"";
MultipartIterator.parseForAttribute(parseString, "name");
That will return "bob".attribute - The name of the attribute you're trying to getparseString - The string to retrieve the value fromnull if none could be foundpublic java.lang.String getHeaderField(java.lang.String name)
name - Field name