Permalink
Browse files

request-header map needs to be copied to avoid REST API calls' keepal…

…ive connection turned off
  • Loading branch information...
1 parent 4181538 commit 2a63ef13662e7cd135321926d315f91681d90ced @yusuke yusuke committed May 9, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 twitter4j-stream/src/main/java/twitter4j/TwitterStreamImpl.java
@@ -27,10 +27,7 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static twitter4j.internal.http.HttpResponseCode.FORBIDDEN;
import static twitter4j.internal.http.HttpResponseCode.NOT_ACCEPTABLE;
@@ -661,7 +658,10 @@ public int getHttpDefaultMaxPerRoute() {
}
public Map<String, String> getRequestHeaders() {
- Map<String, String> headers = nestedConf.getRequestHeaders();
+ // turning off keepalive connection explicitly because Streaming API doesn't need keepalive connection.
+ // and this will reduce the shutdown latency of streaming api connection
+ // see also - http://jira.twitter4j.org/browse/TFJ-556
+ Map<String, String> headers = new HashMap<String, String>(nestedConf.getRequestHeaders());
headers.put("Connection", "close");
return headers;
}

0 comments on commit 2a63ef1

Please sign in to comment.