Giter VIP home page Giter VIP logo

h2c's Issues

--data-binary output should be escaped

Similar to the -F multipart bugs, the strings after --data-bianry are not escaped.

Given this input:

POST / HTTP/1.1
Host: localhost:8000
User-Agent: curl/7.47.0
Accept: */*
Content-Length: 5
Content-Type: application/x-www-form-urlencoded

$PATH

h2c outputs:
curl --http1.1 --user-agent "curl/7.47.0" --data-binary "$PATH" https://localhost:8000/

A POSIX shell will expand $PATH.

handle proxy requests better

GET http://example.com/this HTTP/1.1
Host: example.com
User-Agent: moo/2000

We don't know where the proxy is so we can't generate a perfect command line, but we can do better than now...

$ ./h2c < test-proxy
curl --http1.1 --header Accept: --user-agent "moo/2000" https://example.comhttp://example.com/this

web: provide option to show libcurl code instead

With the new --libcurl option, h2c can now generate libcurl code. The online version should then pipe that through enscript and generate a syntax-highlighted version of the code, and preferably with links on function and option names much like the examples do.

POST with XML data doesn't work

The following input

POST /ws/ HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: no-cache
Content-Type: application/soap+xml
User-Agent: WSDAPI
Content-Length: 645
Host: 10.61.64.55

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"><soap:Header><wsa:To>urn:uuid:3ba66c80-1dd2-11b2-8f68-9c934e243796</wsa:To><wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</wsa:Action><wsa:MessageID>urn:uuid:c949ad8f-925c-4ec0-b110-9484bbbda578</wsa:MessageID><wsa:ReplyTo><wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address></wsa:ReplyTo><wsa:From><wsa:Address>urn:uuid:b2dbd154-99d4-46e4-b4d8-603df5363b18</wsa:Address></wsa:From></soap:Header><soap:Body/></soap:Envelope>

produces

curl --header Accept: --header "Content-Type: application/soap+xml" --header "Cache-Control: no-cache" --header "Connection: Keep-Alive" --header "Pragma: no-cache" --user-agent "WSDAPI" --data-binary "urn:uuid:3ba66c80-1dd2-11b2-8f68-9c934e243796http://schemas.xmlsoap.org/ws/2004/09/transfer/Geturn:uuid:c949ad8f-925c-4ec0-b110-9484bbbda578http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymousurn:uuid:b2dbd154-99d4-46e4-b4d8-603df5363b18" https://10.61.64.55/ws/

But the string after --data-binary is only a part of the real body.

Output isn't quoted when multipart form values include spaces

When a mutlipart form value contains spaces, h2c outputs --form FOO=1 2 3 4 instead of --form 'FOO=1 2 3 4'.

Since h2c's output is a valid shell command, one should be careful with other characters such as ; or ', which may require quoting or escaping.

Wrong output when parsing parameters in multipart form

When several form parameters are provided, the output from h2c is garbled.

This curl command:
curl --form ONE=1 --form TWO=2 --form THREE=3 http://localhost:8000

Performs this request:

POST / HTTP/1.1
Host: localhost:8000
User-Agent: curl/7.47.0
Accept: */*
Content-Length: 327
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------48e1b0f105811e87

--------------------------48e1b0f105811e87
Content-Disposition: form-data; name="ONE"

1
--------------------------48e1b0f105811e87
Content-Disposition: form-data; name="TWO"

2
--------------------------48e1b0f105811e87
Content-Disposition: form-data; name="THREE"

3
--------------------------48e1b0f105811e87--

Which h2c outputs as:

curl --http1.1 --user-agent "curl/7.47.0" --form ONE=1 --form TWO=1
2 --form THREE=1
2
3 https://localhost:8000/

Note that the value of the form fields keeps accumulating instead of resetting. TWO's value is 1\n2 and THREE's value is 1\n2\n3.

wrap url in (double/single) quotes

If the URL contains an ampersand (&) it is interpreted as "run in a different process" in the command line shell.
Wrapping it in quotes might be helpful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.