use of com.koushikdutta.async.http.Multimap in project AndroidAsync by koush.
the class BodyTests method testNullValue.
@Test
public void testNullValue() throws Exception {
Multimap mm = new Multimap();
mm.add("hello", null);
UrlEncodedFormBody body = new UrlEncodedFormBody(mm);
int length = body.length();
}
use of com.koushikdutta.async.http.Multimap in project ion by koush.
the class HttpTests method testCookie.
public void testCookie() throws Exception {
Ion ion = Ion.getDefault(getContext());
ion.getCookieMiddleware().clear();
ion.build(getContext()).load("http://google.com").asString().get();
for (HttpCookie cookie : ion.getCookieMiddleware().getCookieStore().get(URI.create("http://www.google.com"))) {
Log.i("CookieTest", cookie.getName() + ": " + cookie.getValue());
}
assertTrue(ion.getCookieMiddleware().getCookieManager().get(URI.create("http://www.google.com/test/path"), new Multimap()).size() > 0);
CookieMiddleware deserialize = new CookieMiddleware(ion);
assertTrue(deserialize.getCookieManager().get(URI.create("http://www.google.com/test/path"), new Multimap()).size() > 0);
}
use of com.koushikdutta.async.http.Multimap in project AndroidAsync by koush.
the class SpdyMiddleware method newSocket.
private void newSocket(GetSocketData data, final AsyncSpdyConnection connection, final ConnectCallback callback) {
final AsyncHttpRequest request = data.request;
data.protocol = connection.protocol.toString();
final AsyncHttpRequestBody requestBody = data.request.getBody();
// this causes app engine to shit a brick, but if it is missing,
// drive shits the bed
// if (requestBody != null) {
// if (requestBody.length() >= 0) {
// request.getHeaders().set("Content-Length", String.valueOf(requestBody.length()));
// }
// }
final ArrayList<Header> headers = new ArrayList<Header>();
headers.add(new Header(Header.TARGET_METHOD, request.getMethod()));
headers.add(new Header(Header.TARGET_PATH, requestPath(request.getUri())));
String host = request.getHeaders().get("Host");
if (Protocol.SPDY_3 == connection.protocol) {
headers.add(new Header(Header.VERSION, "HTTP/1.1"));
headers.add(new Header(Header.TARGET_HOST, host));
} else if (Protocol.HTTP_2 == connection.protocol) {
// Optional in HTTP/2
headers.add(new Header(Header.TARGET_AUTHORITY, host));
} else {
throw new AssertionError();
}
headers.add(new Header(Header.TARGET_SCHEME, request.getUri().getScheme()));
final Multimap mm = request.getHeaders().getMultiMap();
for (String key : mm.keySet()) {
if (SpdyTransport.isProhibitedHeader(connection.protocol, key))
continue;
for (String value : mm.get(key)) {
headers.add(new Header(key.toLowerCase(Locale.US), value));
}
}
request.logv("\n" + request);
final AsyncSpdyConnection.SpdySocket spdy = connection.newStream(headers, requestBody != null, true);
callback.onConnectCompleted(null, spdy);
}
use of com.koushikdutta.async.http.Multimap in project ion by koush.
the class IonRequestBuilder method setBodyParameter.
@Override
public IonRequestBuilder setBodyParameter(String name, String value) {
if (bodyParameters == null) {
bodyParameters = new Multimap();
setBody(new UrlEncodedFormBody(bodyParameters));
}
if (value != null)
bodyParameters.add(name, value);
return this;
}
use of com.koushikdutta.async.http.Multimap in project ion by koush.
the class IonRequestBuilder method setBodyParameters.
public IonRequestBuilder setBodyParameters(Map<String, List<String>> params) {
if (bodyParameters == null) {
bodyParameters = new Multimap();
setBody(new UrlEncodedFormBody(bodyParameters));
}
bodyParameters.putAll(params);
return this;
}
Aggregations