Всем привет!
Необходимо средствами Delphi (сейчас версия 10.2) создать HTTP post запрос, чтобы он содержал раздел:
HTML5 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| Hypertext Transfer Protocol
POST /clearportsstat?section=STAT HTTP/1.1\r\n
Cache-Control: no-cache\r\n
Connection: Keep-Alive\r\n
Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n
Accept: */*\r\n
Accept-Encoding: gzip, deflate\r\n
Accept-Language: ru-RU\r\n
Referer: [url]http://192.168.10.10/\r\n[/url]
User-Agent: Embarcadero URI Client/1.0\r\n
X-Requested-With: XMLHttpRequest\r\n
DNT: 1\r\n
Content-Length: 3\r\n
Host: 192.168.10.10\r\n
\r\n
[Full request URI: [url]http://192.168.10.10/clearportsstat?section=STAT][/url]
[HTTP request 2/3]
[Prev request in frame: 61]
[Response in frame: 247]
File Data: 3 bytes
HTML Form URL Encoded: application/x-www-form-urlencoded
Form item: "all" = ""
Key: all
Value: |
|
Такой запрос создан в JavaScript методом post(). Переданные данные: all
В Delphi я его создаю так
Delphi |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| HTTPCommandClient := THTTPClient.Create;
with HTTPCommandClient do
begin
ConnectionTimeout := 8000;
ResponseTimeout := 8000;
ContentType := 'application/x-www-form-urlencoded';
Accept := '*/*';
AcceptEncoding := 'gzip, deflate';
AcceptLanguage := 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7';
CustomHeaders['X-Requested-With'] := 'XMLHttpRequest';
CustomHeaders['Referer'] := 'http://' + fIPAddress + '/';
CustomHeaders['Connection'] := 'Keep-alive';
CustomHeaders['Cache-control'] := 'no-cache';
end;
strList := TStringList.Create;
strList.AddPair('all', '');
try
HTTPCommandClient.Post('http://192.168.10.10/clearportsstat?section=STAT', strList);
finally
strList.Free;
HTTPCommandClient.Free;
end; |
|
и получается так:
HTML5 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| Hypertext Transfer Protocol
POST /clearportsstat?section=STAT HTTP/1.1\r\n
Cache-Control: no-cache\r\n
Connection: Keep-Alive\r\n
Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n
Accept: */*\r\n
Accept-Encoding: gzip, deflate\r\n
Accept-Language: ru-RU\r\n
Referer: [url]http://192.168.10.10/\r\n[/url]
User-Agent: Embarcadero URI Client/1.0\r\n
X-Requested-With: XMLHttpRequest\r\n
DNT: 1\r\n
Content-Length: 4\r\n
Host: 192.168.10.10\r\n
\r\n
[Full request URI: [url]http://192.168.10.10/clearportsstat?section=STAT][/url]
[HTTP request 2/2]
[Prev request in frame: 61]
[Response in frame: 247]
File Data: 4 bytes
HTML Form URL Encoded: application/x-www-form-urlencoded
Form item: "all" = ""
Key: all
Value: |
|
Получаю данные в таком виде: all=