public class HttpEasyReader
extends java.lang.Object
| 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.
|
JsonReader |
getJsonReader() |
int |
getResponseCode()
Gets the status code from an HTTP response message, see
HttpURLConnection.getResponseCode(). |
Family |
getResponseCodeFamily()
Gets the family of the status code from an HTTP response message, see
Family. |
java.lang.String |
getResponseHeaderField(java.lang.String name)
Response header field.
|
java.util.List<java.lang.String> |
getResponseHeaderFields(java.lang.String name)
Response header field.
|
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 HttpResponseException,
java.io.IOException
connection - HttpURLConnectionrequest - Request that is creating this readerHttpResponseException - if request failedjava.io.IOException - for connection errorspublic java.net.HttpURLConnection getConnection()
HttpURLConnectionpublic int getResponseCode()
throws java.io.IOException
HttpURLConnection.getResponseCode().java.io.IOExceptionpublic Family getResponseCodeFamily() throws java.io.IOException
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 getResponseHeaderField(java.lang.String name)
getResponseHeaderFields(String).name - Field namepublic java.util.List<java.lang.String> getResponseHeaderFields(java.lang.String name)
name - Field name