public class DefaultWebRequestor extends Object implements WebRequestor
WebRequestor.Response| Constructor and Description |
|---|
DefaultWebRequestor() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeQuietly(Closeable closeable)
Attempts to cleanly close a resource, swallowing any exceptions that might
occur since there's no way to recover anyway.
|
protected void |
closeQuietly(HttpURLConnection httpUrlConnection)
Attempts to cleanly close an
HttpURLConnection, swallowing any
exceptions that might occur since there's no way to recover anyway. |
protected void |
customizeConnection(HttpURLConnection connection)
Hook method which allows subclasses to easily customize the
connections created by executeGet(String) and
executePost(String, String) - for example, setting a custom read
timeout or request header. |
WebRequestor.Response |
executeGet(String url)
Given a Facebook API endpoint URL, execute a
GET against it. |
WebRequestor.Response |
executePost(String url,
String parameters)
Given a Facebook API endpoint URL and parameter string, execute a
POST to the endpoint URL. |
WebRequestor.Response |
executePost(String url,
String parameters,
InputStream binaryAttachment)
Given a Facebook API endpoint URL and parameter string, execute a
POST to the endpoint URL. |
protected void |
write(InputStream source,
OutputStream destination,
int bufferSize)
Writes the contents of the
source stream to the destination
stream using the given bufferSize. |
public WebRequestor.Response executeGet(String url) throws IOException
WebRequestorGET against it.executeGet in interface WebRequestorurl - The URL to make a GET request for, including URL
parameters.IOException - If an error occurs while performing the GET operation.WebRequestor.executeGet(String)public WebRequestor.Response executePost(String url, String parameters) throws IOException
WebRequestorPOST to the endpoint URL.executePost in interface WebRequestorurl - The URL to POST to.parameters - The parameters to be POSTed.IOException - If an error occurs while performing the POST.WebRequestor.executePost(String,
String)public WebRequestor.Response executePost(String url, String parameters, InputStream binaryAttachment) throws IOException
WebRequestorPOST to the endpoint URL.executePost in interface WebRequestorurl - The URL to POST to.parameters - The parameters to be POSTed.binaryAttachment - A binary attachment to be included in the POST body (e.g.
a photo).IOException - If an error occurs while performing the POST.WebRequestor.executePost(String,
String, java.io.InputStream)protected void customizeConnection(HttpURLConnection connection)
connections created by executeGet(String) and
executePost(String, String) - for example, setting a custom read
timeout or request header.
This implementation is a no-op.connection - The connection to customize.protected void closeQuietly(Closeable closeable)
null in, this method will no-op in that case.closeable - The resource to close.protected void closeQuietly(HttpURLConnection httpUrlConnection)
HttpURLConnection, swallowing any
exceptions that might occur since there's no way to recover anyway.
It's OK to pass null in, this method will no-op in that case.httpUrlConnection - The connection to close.protected void write(InputStream source, OutputStream destination, int bufferSize) throws IOException
source stream to the destination
stream using the given bufferSize.source - The source stream to copy from.destination - The destination stream to copy to.bufferSize - The size of the buffer to use during the copy operation.IOException - If an error occurs when reading from source or writing to
destination.NullPointerException - If either source or @{code destination} is null.Copyright © 2014. All rights reserved.