The website communicates with the server as follows:

Hypertext Transfer Protocol POST /cost_calc.php HTTP/1.1\r\n [Expert Info (Chat/Sequence): POST /cost_calc.php HTTP/1.1\r\n] [POST /cost_calc.php HTTP/1.1\r\n] [Severity level: Chat] [Group: Sequence] Request Method: POST Request URI: /cost_calc.php Request Version: HTTP/1.1 Host: example.com\r\n User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0\r\n Accept: */*\r\n Accept-Language: en-US,en;q=0.5\r\n Accept-Encoding: gzip, deflate\r\n Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n X-Requested-With: XMLHttpRequest\r\n Referer: http://example.com/\r\n Content-Length: 1266\r\n [Content length: 1266] Cookie: _ga=GA1.3.187715172.1481965656; _gat_UA-76707418-1=1\r\n Cookie pair: _ga=GA1.3.187715172.1481965656 Cookie pair: _gat_UA-76707418-1=1 DNT: 1\r\n Connection: keep-alive\r\n \r\n [Full request URI: http://example.com/cost_calc.php] [HTTP request 1/4] [Response in frame: 8] [Next request in frame: 11] File Data: 1266 bytes HTML Form URL Encoded: application/x-www-form-urlencoded Form item: "data" = "{"user_full_name":"邪薪写褉械泄","user_phone":"(111)111-11-11","client_sub_card":null,"required_time":null,"reservation":false,"route_address_entrance_from":"","comment":"锌褉懈胁械褌","add_cost":0,"wagon":false,"minib Key: data Value [truncated]: {"user_full_name":"\320\260\320\275\320\264\321\200\320\265\320\271","user_phone":"(111)111-11-11","client_sub_card":null,"required_time":null,"reservation":false,"route_address_entrance_from":"","comment":"\320\277\321\ Form item: "url" = "http://194.183.173.18:7200/api/weborders/cost" Key: url Value: http://194.183.173.18:7200/api/weborders/cost Hypertext Transfer Protocol HTTP/1.1 200 OK\r\n [Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n] [HTTP/1.1 200 OK\r\n] [Severity level: Chat] [Group: Sequence] Request Version: HTTP/1.1 Status Code: 200 Response Phrase: OK Server: nginx/1.10.2\r\n Date: Mon, 02 Jan 2017 12:13:54 GMT\r\n Content-Type: text/html; charset=UTF-8\r\n Transfer-Encoding: chunked\r\n Connection: keep-alive\r\n Vary: Accept-Encoding\r\n Content-Encoding: gzip\r\n \r\n [HTTP response 1/4] [Time since request: 0.306525000 seconds] [Request in frame: 5] [Next request in frame: 11] [Next response in frame: 14] HTTP chunked response Data chunk (144 octets) Chunk size: 144 octets Data (144 bytes) 0000 1f 8b 08 00 00 00 00 00 00 03 2d cd 4d 0a c2 30 ..........-.M..0 0010 10 40 e1 ab c8 ac 45 48 53 4b d3 cb 84 c9 64 a2 .@....EHSK....d. 0020 01 49 42 7e 16 a5 08 de c9 b5 77 a8 37 32 a2 db .IB~......w.72.. 0030 8f 07 6f 03 eb 4b c2 4a 57 1f 2e 3a 66 cb 59 37 ..o..K.JW..:f.Y7 0040 6f 61 01 69 78 98 49 8c c6 4c 34 4e 42 ce 52 91 oa.ix.I..L4NB.R. 0050 38 1b 87 03 3a 29 15 c3 11 7e 39 c5 52 bf bd 50 8...:)...~9.R..P 0060 9d a8 e5 cc 81 d6 0e 87 fd f9 7e ec af 53 d7 fe ..........~..S.. 0070 a0 d8 42 d5 35 fb 04 8b c3 5b e1 de 62 d0 09 57 ..B.5....[..b..W 0080 6d 62 68 85 cb df ef 1f d3 04 5e 0d 93 00 00 00 mbh.......^..... Data: 1f8b08000000000000032dcd4d0ac2301040e1abc8ac4548... [Length: 144] Chunk boundary: 0d0a End of chunked encoding Chunk size: 0 octets \r\n Content-encoded entity body (gzip): 144 bytes -> 147 bytes File Data: 147 bytes Line-based text data: text/html {"dispatching_order_uid":"3be28c14bb6c4613839c15bfa2af339e","order_cost":"319","currency":" \320\263\321\200\320\275.","discount_trip":false,"can_pay_bonuses":false} 

How to simulate this communication using an Android application?

I try to send a request in the form:

 HttpPost httppost = new HttpPost(host + app); String toSend = "HTML Form URL Encoded: application/x-www-form-urlencoded\n" + //" Form item: \"data\" = \""+params[0]+"\"\n" + " Form item: \"data\" = \"{\"user_full_name\":\"Andrew\",\"user_phone\":\"(111)111-11-11\",\"client_sub_card\":null,\"required_time\":null,\"reservation\":false,\"route_address_entrance_from\":\"\",\"comment\":\"\",\"add_cost\":0,\"wagon\":false,\"minibus\":false,\"premium\":false,\"flexible_tariff_name\":\"袘邪蟹芯胁褘泄\",\"baggage\":false,\"animal\":false,\"conditioner\":false,\"courier_delivery\":false,\"route_undefined\":false,\"terminal\":false,\"receipt\":false,\"route\":[{\"name\":\"袛袗袙蝎袛袨袙袗 袗袥袝袣小袝携 袘校袥鞋袙.\",\"number\":\"3\"},{\"name\":\"笑校袥校袣袠袛袟袝 校袥.\",\"number\":\"12\"}],\"taxiColumnId\":0,\"app_registration_token\":\"\",\"pay_bonuses\":0}\n" + " Form item: \"url\" = \"http://194.183.173.18:7200/api/weborders/cost\""; try { toSend= URLEncoder.encode(toSend, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } httppost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"); httppost.setHeader("Accept","*/*"); httppost.setHeader("Accept-Language", "en-us,en;q=0.5"); httppost.setHeader("Accept-Encoding", "gzip, deflate"); httppost.setHeader("Cookie", "_ga=GA1.3.187715172.1481965656"); httppost.setHeader("Content-Type","application/x-www-form-urlencoded"); httppost.setHeader("X-Requested-With", "XMLHttpRequest"); httppost.setHeader("DNT", "1"); try { httppost.setEntity(new StringEntity(toSend)); HttpResponse response = httpclient.execute(httppost); responseStr = EntityUtils.toString(response.getEntity()); Log.d(LOG_TAG, responseStr); } catch (Exception e) { e.printStackTrace(); } return responseStr; 

and I get back just OK without data.

  • Describe what kind of request you want to make to the server. judging by the code you are not correctly transmitting data. for android there is a good library OkHttp . try it. - Mikhail Vaysman
  • one
    toSend looks pretty crazy. Are you sure that the data should be sent in this format? - Alexey Ten
  • @Alexey Ten if I was sure, I would not have written here. This is the n-th attempt. - Andrew Romanenko
  • @Mikhail Vaysman thanks for the library. The correct request-answer is in the dump. I have already tried many options. - Andrew Romanenko
  • dump must be inserted into the message - Mikhail Vaysman

0