|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.shindig.gadgets.http.BasicHttpFetcher
public class BasicHttpFetcher
A simple HTTP fetcher implementation based on Apache httpclient. Not recommended for production deployments until the following issues are addressed:
1. This class potentially allows access to resources behind an organization's firewall. 2. This class does not enforce any limits on what is fetched from remote hosts.
| Field Summary | |
|---|---|
protected org.apache.http.client.HttpClient |
FETCHER
|
| Constructor Summary | |
|---|---|
BasicHttpFetcher(int maxObjSize,
int connectionTimeoutMs,
int readTimeoutMs,
String basicHttpFetcherProxy)
Creates a new fetcher for fetching HTTP objects. |
|
BasicHttpFetcher(String basicHttpFetcherProxy)
Creates a new fetcher using the default maximum object size and timeout -- no limit and 5 seconds. |
|
| Method Summary | |
|---|---|
HttpResponse |
fetch(HttpRequest request)
Fetch HTTP content. |
void |
setConnectionTimeoutMs(int connectionTimeoutMs)
Change the global connection timeout for all new fetchs. |
void |
setMaxObjectSizeBytes(int maxObjectSizeBytes)
Change the global maximum fetch size (in bytes) for all fetches. |
void |
setReadTimeoutMs(int readTimeoutMs)
Change the global read timeout for all new fetchs. |
void |
setSlowResponseWarning(long slowResponseWarning)
Change the global threshold for warning about slow responses |
protected void |
slowResponseWarning(HttpRequest request,
long started,
long finished)
Called when a request takes too long. |
byte[] |
toByteArraySafe(org.apache.http.HttpEntity entity)
This method is Safe replica version of org.apache.http.util.EntityUtils.toByteArray. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final org.apache.http.client.HttpClient FETCHER
| Constructor Detail |
|---|
@Inject
public BasicHttpFetcher(@Nullable
String basicHttpFetcherProxy)
basicHttpFetcherProxy - The http proxy to use.
public BasicHttpFetcher(int maxObjSize,
int connectionTimeoutMs,
int readTimeoutMs,
String basicHttpFetcherProxy)
maxObjSize - Maximum size, in bytes, of the object we will fetch, 0 if no limit..connectionTimeoutMs - timeout, in milliseconds, for connecting to hosts.readTimeoutMs - timeout, in millseconds, for unresponsive connectionsbasicHttpFetcherProxy - The http proxy to use.| Method Detail |
|---|
public HttpResponse fetch(HttpRequest request)
throws GadgetException
HttpFetcher
fetch in interface HttpFetcherrequest - The request to fetch.
GadgetException - In the event of a failure that can't be mapped to an HTTP result code.
protected void slowResponseWarning(HttpRequest request,
long started,
long finished)
request - the request that generated the slowrequeststarted - the time the request started, in milliseconds.finished - the time the request finished, in milliseconds.@Inject(optional=true) public void setMaxObjectSizeBytes(int maxObjectSizeBytes)
maxObjectSizeBytes - value for maximum number of bytes, or 0 for no limit@Inject(optional=true) public void setSlowResponseWarning(long slowResponseWarning)
slowResponseWarning - time in milliseconds after we issue a warning@Inject(optional=true) public void setConnectionTimeoutMs(int connectionTimeoutMs)
connectionTimeoutMs - new connection timeout in milliseconds@Inject(optional=true) public void setReadTimeoutMs(int readTimeoutMs)
readTimeoutMs - new connection timeout in milliseconds
public byte[] toByteArraySafe(org.apache.http.HttpEntity entity)
throws IOException
entity -
IOException - if an error occurs reading the input stream
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||