项目作者: curl

项目描述 :
headers 2 curl. Provided a set of HTTP request headers, output the curl command line for generating that set. Try the converter online at
高级语言: Perl
项目地址: git://github.com/curl/h2c.git
创建时间: 2017-08-28T12:01:42Z
项目社区:https://github.com/curl/h2c

开源协议:MIT License

下载


h2c

headers 2 curl. Provided a set of HTTP request headers, output the curl command line for generating that set.

  1. $ cat test
  2. HEAD / HTTP/1.1
  3. Host: curl.se
  4. User-Agent: moo
  5. Shoesize: 12
  6. $ ./h2c < test
  7. curl --head --http1.1 --header Accept: --user-agent "moo" --header "Shoesize: 12" https://curl.se/

or a more complicated one:

  1. $ cat test2
  2. PUT /this is me HTTP/2
  3. Host: curl.se
  4. User-Agent: moo on you all
  5. Shoesize: 12
  6. Cookie: a=12; b=23
  7. Content-Type: application/json
  8. Content-Length: 57
  9. {"I do not speak": "jason"}
  10. {"I do not write": "either"}
  11. $ ./h2c < test2
  12. curl --http2 --header Accept: --user-agent "moo on you all" --header "shoesize: 12" --cookie "a=12; b=23" --header "content-type: application/json" --data-binary "{\"I do not speak\": \"jason\"} {\"I do not write\": \"either\"}" --request PUT "https://curl.se/this is me"

multipart!

  1. $ cat multipart
  2. POST /upload HTTP/1.1
  3. Host: example.com
  4. User-Agent: curl/7.55.0
  5. Accept: */*
  6. Content-Length: 1236
  7. Expect: 100-continue
  8. Content-Type: multipart/form-data; boundary=------------------------2494bcbbb6e66a98
  9. --------------------------2494bcbbb6e66a98
  10. Content-Disposition: form-data; name="name"
  11. moo
  12. --------------------------2494bcbbb6e66a98
  13. Content-Disposition: form-data; name="file"; filename="README.md"
  14. Content-Type: application/octet-stream
  15. contents
  16. --------------------------2494bcbbb6e66a98--
  17. $ ./h2c < multipart
  18. curl --http1.1 --user-agent "curl/7.55.0" --form name=moo --form file=@README.md https://example.com/upload

authentication

  1. $ cat basic
  2. GET /index.html HTTP/2
  3. Host: example.com
  4. Authorization: Basic aGVsbG86eW91Zm9vbA==
  5. Accept: */*
  6. $ ./h2c < basic
  7. curl --http2 --header User-Agent: --user "hello:youfool" https://example.com/index.html