S
S
Sergey Zhukovsky2015-01-06 09:52:36
JSON
Sergey Zhukovsky, 2015-01-06 09:52:36

How to send a Cyrillic POST request in JSON format?

Hello. I'm trying to send a POST request to a website from a C# application. The problem is that Cyrillic characters are distorted during transmission, although everything is fine from the browser.
Here is a POST request with headers from the browser:

POST URL HTTP/1.1
Host: URL
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
Accept: application/json, text/plain, */*
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/json;charset=utf-8
Referer: URL
Content-Length: 29
Cookie: session="2f3efce229$2a$10$3SqRUSaaEiFD2ItE/M37VO"; remember=3e2c6bd983$2a$10$KnFomIqWAMls8kVTHMGjl; i18next=ru-RU
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
 
{"message":"Привет :)"}

Here is the server response:
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 04 Jan 2015 11:14:10 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 124
Connection: keep-alive
 
{"id":"54a91fe0e4b0093d4982d09b","message":"Привет :)","inbox":false,"unread":false,"date":"2015-01-04T11:11:28.272Z"}

I do the same through the application:
Here are the headers:
POST URL HTTP/1.1
User-Agent: User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
Host: URL
Cookie: session="2f3efce229$2a$10$3SqRUSaaEiFD2ItE/M37VO"; remember=3e2c6bd983$2a$10$KnFomIqWAMls8kVTHMGjl; i18next=ru-RU
Content-Type: application/json;charset=utf-8
Cache-Control: no-cache
Pragma: no-cache
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept: application/json, text/plain, */*
Referer: URL
Content-Length: 23

{"message":"       :)"}

As you can see, the encoding is already flies.
if the encoding windows-1251 is specified in the POST request, then it is displayed normally in the request, but the answer comes back anyway with a curve.
Where to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan_Brezovskiy, 2021-04-07
@Ruslan_Brezovskiy

You have a different Content-Length value in two requests, it should be 29, not 23, since Russian characters take up two bytes. If you encounter such a problem using Yandex.tank, then the sum of the bytes of the entire request should be increased

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question