i have upgraded dropwizard 0.8 uses jetty -9 server. using volley server 1.0.15 send json request app. problem when send json volley api throws 400 while when send same request postman working fine.
warn [2015-05-08 14:16:18,223] org.eclipse.jetty.http.httpparser: illegal character 0x16 in state=start buffer heapbytebuffer@642bbd0f[p=1,l=78,c=8192,r=77]={\x16<<<\x03\x00\x00i\x01\x00\x00e\x03\x00\xbfe\x8e\x82\xcb\xe3\xca...\x07\xc0\x11\x00/\x005\x00\x05\x00\xffv\x00\x01\x00>>>-1\r\ncontent-lengt...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00} warn [2015-05-08 14:16:18,223] org.eclipse.jetty.http.httpparser: badmessage: 400 illegal character 0x16 httpchanneloverhttp@650d154b{r=0,c=false,a=idle,uri=-}
and code make volley request
jsonobject userdetails = new jsonobject(); userdetails.put("email", "tasneem"); userdetails.put("password", "1234"); userdetails.put("deviceid", "243243"); userdetails.put("version", "4.4.4"); userdetails.put("platform", "android"); jsonobjectrequest loginrequest = new jsonobjectrequest(request.method.post, constants.url_login, userdetails, new response.listener<jsonobject>() { @override public void onresponse(jsonobject jsonobject) { } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror volleyerror) { log.e(tag, volleyerror.tostring()); mlistener.onerror(volleyerror); } }) { @override public map<string, string> getheaders() throws authfailureerror { map<string, string> headers = new hashmap<string, string>(); headers.put("content-type", "application/json; charset=utf-8"); return headers; } };
really appreciate help. thanks.
and can tell me how trace complete request without creating custom volley request, there way?
i traced packets sent in wireshark , found in header, content-type
mentioned twice.
content-type: application/json; charset=utf-8\r\n content-type: application/json; charset=utf-8\r\n user-agent: dalvik/1.6.0 (linux; u; android 4.4.2; htc desire 526gplus dual sim build/kot49h)\r\n . . .
removing overriden method getheaders() worked
@override public map<string, string> getheaders() throws authfailureerror { map<string, string> headers = new hashmap<string, string>(); headers.put("content-type", "application/json; charset=utf-8"); return headers; }
the override not required because in com.android.volley.toolbox.jsonrequest.java
, content-type
set application/json; charset=utf-8
, seems dropwizard 0.8 not take same header twice.
Comments
Post a Comment