[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How is http request via /dev/tcp different from that of curl?
From: |
alex xmb sw ratchev |
Subject: |
Re: How is http request via /dev/tcp different from that of curl? |
Date: |
Sat, 18 May 2024 10:29:10 +0200 |
both tools i mentioned can put multiple user http requests , depending on
httpd 2's
they connect , and send user data , and recieve
say u can send 3 requests , then read ..
ita not ' those tools dont support multi request ' - thats wrong knowledge
On Fri, May 17, 2024, 20:03 Peng Yu <pengyu.ut@gmail.com> wrote:
> Please use proper grammar. I am not following you.
>
> On Fri, May 17, 2024 at 10:06 AM alex xmb sw ratchev <fxmbsw7@gmail.com>
> wrote:
>
>>
>>
>> On Fri, May 17, 2024, 13:44 Peng Yu <pengyu.ut@gmail.com> wrote:
>>
>>> I know. But I need to establish one tcp connection and submit multiple
>>> requests using the same connection. I don’t want the connection be closed
>>> while I process the response. None external tools can achieve this.
>>>
>>
>> what , ur dreaming ..
>> if u http request , and the httpd is valid , u can send all kinds of http
>> supported multi-things*
>> no matter what tool all work
>> its up to u having to make the http request n headers
>> if u do well , and the httpd is not too junk , it ll work , no matter
>> which tool
>>
>> On Fri, May 17, 2024 at 5:40 AM alex xmb sw ratchev <fxmbsw7@gmail.com>
>>> wrote:
>>>
>>>> other tools to make tcp scripts are socat
>>>> http://www.dest-unreach.org/socat/ and tcpclient and tcpserver from
>>>> ucspi-tcp https://cr.yp.to/ucspi-tcp.html
>>>>
>>>> On Fri, May 17, 2024, 01:25 Peng Yu <pengyu.ut@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> $ curl 'http://httpbin.org/get' -H 'User-Agent: Mozilla/5.0
>>>>> (Macintosh; Intel Mac OS X 10.15; rv:125.0) Gecko/20100101
>>>>> Firefox/125.0' -H 'Accept: application/json' -H 'Accept-Language:
>>>>> en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'Referer:
>>>>> http://httpbin.org/' -H 'DNT: 1' -H 'Sec-GPC: 1' -H 'Connection:
>>>>> keep-alive'
>>>>> {
>>>>> "args": {},
>>>>> "headers": {
>>>>> "Accept": "application/json",
>>>>> "Accept-Encoding": "gzip, deflate",
>>>>> "Accept-Language": "en-US,en;q=0.5",
>>>>> "Dnt": "1",
>>>>> "Host": "httpbin.org",
>>>>> "Referer": "http://httpbin.org/",
>>>>> "Sec-Gpc": "1",
>>>>> "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15;
>>>>> rv:125.0) Gecko/20100101 Firefox/125.0",
>>>>> "X-Amzn-Trace-Id": "Root=1-66469337-0aab56e96f4fee271f6a09ce"
>>>>> },
>>>>> "origin": "xxx.xxx.xxx.xxx",
>>>>> "url": "http://httpbin.org/get"
>>>>> }
>>>>>
>>>>> I want to replicate the same thing in bash below. But the result is
>>>>> not the same. How is the bash http request via /dev/tcp different from
>>>>> that of curl?
>>>>>
>>>>> exec {fd}<>/dev/tcp/httbin.org/80
>>>>>
>>>>> echo -e "GET /get HTTP/1.1\r
>>>>> Host: httpbin.org\r
>>>>> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:125.0)
>>>>> Gecko/20100101 Firefox/125.0\r
>>>>> Accept: application/json\r
>>>>> Accept-Language: en-US,en;q=0.5\r
>>>>> Accept-Encoding: gzip, deflate\r
>>>>> Referer: http://httpbin.org/\r
>>>>> DNT: 1\r
>>>>> Sec-GPC: 1\r
>>>>> Connection: keep-alive\r
>>>>> \r" >&"$fd"
>>>>>
>>>>> function httpprotocol/recv {
>>>>> while IFS= read -u "$fd" -r; do
>>>>> if [[ $REPLY =~ ^([^:]+):\ *(.*)$'\r'$ ]]; then
>>>>> headers[${BASH_REMATCH[1],,}]=${BASH_REMATCH[2]}
>>>>> elif [[ $REPLY = $'\r' ]]; then
>>>>> LC_ALL=C read -u "$fd" -r -d '' -N "${headers[content-length]}"
>>>>> body
>>>>> break
>>>>> fi
>>>>> printf -v REPLY '%q' "$REPLY"
>>>>> echo "$REPLY"
>>>>> done
>>>>> }
>>>>>
>>>>> declare -A headers
>>>>> $ httpprotocol/recv
>>>>> $'HTTP/1.1 200 OK\r'
>>>>> $'accept-ch: Sec-CH-UA, Sec-CH-UA-Platform,
>>>>> Sec-CH-UA-Platform-Version, Sec-CH-UA-Mobile\r'
>>>>> $'cache-control: max-age=0, private, must-revalidate\r'
>>>>> $'connection: close\r'
>>>>> $'content-length: 475\r'
>>>>> $'content-type: text/html; charset=utf-8\r'
>>>>> $'date: Thu, 16 May 2024 23:18:56 GMT\r'
>>>>> $'server: nginx\r'
>>>>> $'set-cookie: sid=ab0e69e8-13da-11ef-911e-ea384f7d4599; path=/;
>>>>> domain=.httpbin.org; expires=Wed, 04 Jun 2092 02:33:03 GMT;
>>>>> max-age=2147483647; HttpOnly\r'
>>>>>
>>>>> $ declare -p headers
>>>>> declare -A headers=([server]="nginx" [connection]="close"
>>>>> [content-type]="text/html; charset=utf-8" [cache-control]="max-age=0,
>>>>> private, must-revalidate"
>>>>> [set-cookie]="sid=ab0e69e8-13da-11ef-911e-ea384f7d4599; path=/;
>>>>> domain=.httpbin.org; expires=Wed, 04 Jun 2092 02:33:03 GMT;
>>>>> max-age=2147483647; HttpOnly" [content-length]="475"
>>>>> [accept-ch]="Sec-CH-UA, Sec-CH-UA-Platform,
>>>>> Sec-CH-UA-Platform-Version, Sec-CH-UA-Mobile" [date]="Thu, 16 May 2024
>>>>> 23:18:56 GMT" )
>>>>> $ echo "$body"
>>>>> <html><head><title>Loading...</title></head><body><script
>>>>> type='text/javascript'>window.location.replace('
>>>>> http://httpbin.org/get?ch=1&js=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJKb2tlbiIsImV4cCI6MTcxNTkwODczNiwiaWF0IjoxNzE1OTAxNTM2LCJpc3MiOiJKb2tlbiIsImpzIjoxLCJqdGkiOiIydjgxbW1wajdvc2w5b2M4M2swMHBwNmMiLCJuYmYiOjE3MTU5MDE1MzYsInRzIjoxNzE1OTAxNTM2NTQzNzg3fQ.Bc07CLhZ_HLw5QwfQoWotZPfoegQMRYc84bD-Wqg96k&sid=ab0e69e8-13da-11ef-911e-ea384f7d4599')
>>>>> ;</script></body></html>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Peng
>>>>>
>>>>> --
>>> Regards,
>>> Peng
>>>
>> --
> Regards,
> Peng
>
- How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/16
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/16
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/16
- Re: How is http request via /dev/tcp different from that of curl?, alex xmb sw ratchev, 2024/05/17
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/17
- Re: How is http request via /dev/tcp different from that of curl?, alex xmb sw ratchev, 2024/05/17
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/17
- Re: How is http request via /dev/tcp different from that of curl?,
alex xmb sw ratchev <=
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/19
- Re: How is http request via /dev/tcp different from that of curl?, alex xmb sw ratchev, 2024/05/19
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/19
- Re: How is http request via /dev/tcp different from that of curl?, alex xmb sw ratchev, 2024/05/19
- Re: How is http request via /dev/tcp different from that of curl?, alex xmb sw ratchev, 2024/05/19
- Re: How is http request via /dev/tcp different from that of curl?, alex xmb sw ratchev, 2024/05/19
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/20
- Re: How is http request via /dev/tcp different from that of curl?, alex xmb sw ratchev, 2024/05/20
- Re: How is http request via /dev/tcp different from that of curl?, Peng Yu, 2024/05/20