Permalink
Browse files

TFJ-651 pass stall_warnings parameter to endpoints

  • Loading branch information...
1 parent 3f4ded9 commit 9539f10ec69587d8df69bbf2d958872cd91416ee @yusuke committed Jul 17, 2012
@@ -139,7 +139,7 @@ public FilterQuery locations(double[][] locations) {
return this;
}
- /*package*/ HttpParameter[] asHttpParameterArray() {
+ /*package*/ HttpParameter[] asHttpParameterArray(HttpParameter stallWarningsParam) {
ArrayList<HttpParameter> params = new ArrayList<HttpParameter>();
params.add(new HttpParameter("count", count));
@@ -155,6 +155,7 @@ public FilterQuery locations(double[][] locations) {
params.add(new HttpParameter("locations"
, toLocationsString(locations)));
}
+ params.add(stallWarningsParam);
HttpParameter[] paramArray = new HttpParameter[params.size()];
return params.toArray(paramArray);
}
@@ -48,10 +48,15 @@
private List<ConnectionLifeCycleListener> lifeCycleListeners = new ArrayList<ConnectionLifeCycleListener>(0);
private TwitterStreamConsumer handler = null;
+ private String stallWarningsGetParam;
+ private HttpParameter stallWarningsParam;
+
/*package*/
TwitterStreamImpl(Configuration conf, Authorization auth) {
super(conf, auth);
http = new HttpClientWrapper(new StreamingReadTimeoutConfiguration(conf));
+ stallWarningsGetParam = "stall_warnings=" + (conf.isStallWarningsEnabled() ? "true" : "false");
+ stallWarningsParam = new HttpParameter("stall_warnings", conf.isStallWarningsEnabled());
}
/* Streaming API */
@@ -110,7 +115,8 @@ private StatusStream getCountStream(String relativeUrl, int count) throws Twitte
ensureAuthorizationEnabled();
try {
return new StatusStreamImpl(getDispatcher(), http.post(conf.getStreamBaseURL() + relativeUrl
- , new HttpParameter[]{new HttpParameter("count", String.valueOf(count))}, auth), conf);
+ , new HttpParameter[]{new HttpParameter("count", String.valueOf(count))
+ , stallWarningsParam}, auth), conf);
} catch (IOException e) {
throw new TwitterException(e);
}
@@ -140,7 +146,7 @@ public StatusStream getRetweetStream() throws TwitterException {
ensureAuthorizationEnabled();
try {
return new StatusStreamImpl(getDispatcher(), http.post(conf.getStreamBaseURL() + "statuses/retweet.json"
- , new HttpParameter[]{}, auth), conf);
+ , new HttpParameter[]{stallWarningsParam}, auth), conf);
} catch (IOException e) {
throw new TwitterException(e);
}
@@ -169,8 +175,8 @@ public StatusStream getStream() throws TwitterException {
public StatusStream getSampleStream() throws TwitterException {
ensureAuthorizationEnabled();
try {
- return new StatusStreamImpl(getDispatcher(), http.get(conf.getStreamBaseURL() + "statuses/sample.json"
- , auth), conf);
+ return new StatusStreamImpl(getDispatcher(), http.get(conf.getStreamBaseURL() + "statuses/sample.json?"
+ + stallWarningsGetParam, auth), conf);
} catch (IOException e) {
throw new TwitterException(e);
}
@@ -220,6 +226,7 @@ public UserStream getUserStream(String[] track) throws TwitterException {
ensureAuthorizationEnabled();
try {
List<HttpParameter> params = new ArrayList<HttpParameter>();
+ params.add(stallWarningsParam);
if (conf.isUserStreamRepliesAllEnabled()) {
params.add(new HttpParameter("replies", "all"));
}
@@ -281,8 +288,8 @@ InputStream getSiteStream(boolean withFollowings, long[] follow) throws TwitterE
return http.post(conf.getSiteStreamBaseURL() + "/2b/site.json",
new HttpParameter[]{
new HttpParameter("with", withFollowings ? "followings" : "user")
- , new HttpParameter("follow", z_T4JInternalStringUtil.join(follow))}
- , auth).asStream();
+ , new HttpParameter("follow", z_T4JInternalStringUtil.join(follow))
+ , stallWarningsParam}, auth).asStream();
}
/**
@@ -310,7 +317,7 @@ public StatusStream getFilterStream(FilterQuery query) throws TwitterException {
try {
return new StatusStreamImpl(getDispatcher(), http.post(conf.getStreamBaseURL()
+ "statuses/filter.json"
- , query.asHttpParameterArray(), auth), conf);
+ , query.asHttpParameterArray(stallWarningsParam), auth), conf);
} catch (IOException e) {
throw new TwitterException(e);
}

0 comments on commit 9539f10

Please sign in to comment.