Revert Android websocket: Include cookies with request

Summary:
This reverts the commit bf8b5499bb
Pull request: https://github.com/facebook/react-native/pull/6851
Internal Phabricator revision: D3257466

See the pull request for discussion.

Reviewed By: bestander

Differential Revision: D3277433

fbshipit-source-id: 623f93e1bce47ac156ffab154c57495b85ffa936
This commit is contained in:
Martin Konicek 2016-05-09 13:36:34 -07:00 committed by Facebook Github Bot 3
parent d4f6f61a96
commit 128d93b8aa
2 changed files with 0 additions and 31 deletions

View File

@ -7,7 +7,6 @@ android_library(
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common:common'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/modules/network:network'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),

View File

@ -28,7 +28,6 @@ import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.network.ForwardingCookieHandler;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
@ -40,7 +39,6 @@ import com.squareup.okhttp.ws.WebSocketListener;
import java.net.URISyntaxException;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -52,12 +50,10 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
private Map<Integer, WebSocket> mWebSocketConnections = new HashMap<>();
private ReactContext mReactContext;
private ForwardingCookieHandler cookieHandler;
public WebSocketModule(ReactApplicationContext context) {
super(context);
mReactContext = context;
cookieHandler = new ForwardingCookieHandler(context);
}
private void sendEvent(String eventName, WritableMap params) {
@ -84,11 +80,6 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
.tag(id)
.url(url);
String cookie = getCookie(url);
if (cookie != null) {
builder.addHeader("Cookie", getCookie(url));
}
if (headers != null) {
ReadableMapKeySetIterator iterator = headers.keySetIterator();
@ -281,25 +272,4 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
}
}
/**
* Get cookie if exists
*
* @param websocket uri
* @return A cookie / null
*/
private String getCookie(String uri){
try {
Map<String, List<String>> cookieMap = cookieHandler.get(new URI(setDefaultOrigin(uri)), new HashMap());
List<String> cookieList = cookieMap.get("Cookie");
if (cookieList != null) {
return cookieList.get(0);
} else {
return null;
}
} catch(URISyntaxException | IOException e) {
throw new IllegalArgumentException("Unable to get cookie from the " + uri);
}
}
}