Normalize curl command line debug with the url at the end.

This commit is contained in:
jcamiel 2022-12-09 15:00:12 +01:00
parent 38c47501ab
commit ec30da5b05
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
45 changed files with 185 additions and 175 deletions

View File

@ -1,2 +1,2 @@
curl 'https://localhost:8001/hello' --cacert ssl/cert.pem
curl 'https://localhost:8001/hello' --cacert ssl/cert.pem
curl --cacert ssl/cert.pem 'https://localhost:8001/hello'
curl --cacert ssl/cert.pem 'https://localhost:8001/hello'

View File

@ -1,3 +1,3 @@
curl 'https://localhost:8001/hello' --insecure
curl 'https://localhost:8001/hello' --insecure
curl --insecure 'https://localhost:8001/hello'
curl --insecure 'https://localhost:8001/hello'

View File

@ -1,4 +1,4 @@
curl 'https://localhost:8001/hello' --insecure
curl 'https://localhost:8001/hello' --insecure
curl 'https://localhost:8001/hello' --cacert ssl/cert.pem
curl --insecure 'https://localhost:8001/hello'
curl --insecure 'https://localhost:8001/hello'
curl --cacert ssl/cert.pem 'https://localhost:8001/hello'

View File

@ -1 +1 @@
curl 'http://localhost:8000/basic-authentication' --user 'bob@email.com:secret'
curl --user 'bob@email.com:secret' 'http://localhost:8000/basic-authentication'

View File

@ -1,3 +1,3 @@
curl 'http://bob%40email.com:secret@localhost:8000/basic-authentication-per-request'
curl 'http://localhost:8000/basic-authentication-per-request' -H 'Authorization: Basic Ym9iQGVtYWlsLmNvbTpzZWNyZXQ='
curl 'http://localhost:8000/basic-authentication-per-request' -H 'Authorization: Basic Ym9iQGVtYWlsLmNvbTpzZWNyZXQ='
curl -H 'Authorization: Basic Ym9iQGVtYWlsLmNvbTpzZWNyZXQ=' 'http://localhost:8000/basic-authentication-per-request'
curl -H 'Authorization: Basic Ym9iQGVtYWlsLmNvbTpzZWNyZXQ=' 'http://localhost:8000/basic-authentication-per-request'

View File

@ -1,2 +1,2 @@
curl 'http://localhost:8000/utf8_bom'
curl 'http://localhost:8000/mirror' -H 'Content-Type:' --data '@tests_ok/bom.hurl'
curl -H 'Content-Type:' --data '@tests_ok/bom.hurl' 'http://localhost:8000/mirror'

View File

@ -1,2 +1,2 @@
curl 'http://localhost:8000/utf8_bom'
curl 'http://localhost:8000/mirror' -H 'Content-Type:' --data '@tests_ok\bom.hurl'
curl -H 'Content-Type:' --data '@tests_ok\bom.hurl' 'http://localhost:8000/mirror'

View File

@ -1,20 +1,20 @@
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl --compressed 'http://localhost:8000/compressed/none'
curl --compressed 'http://localhost:8000/compressed/none'
curl --compressed 'http://localhost:8000/compressed/none'
curl --compressed 'http://localhost:8000/compressed/none'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/zlib'
curl --compressed 'http://localhost:8000/compressed/zlib'
curl --compressed 'http://localhost:8000/compressed/zlib'
curl --compressed 'http://localhost:8000/compressed/zlib'
# curl needs to be built with brotli support
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli_large' --compressed
curl 'http://localhost:8000/compressed/brotli_identity' --compressed
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli_large'
curl --compressed 'http://localhost:8000/compressed/brotli_identity'

View File

@ -1 +1 @@
curl 'http://localhost:8000/cookie_file' --cookie tests_ok/cookie_file.cookies
curl --cookie tests_ok/cookie_file.cookies 'http://localhost:8000/cookie_file'

View File

@ -1,4 +1,4 @@
curl 'http://localhost:8000/cookie-storage/assert-that-cookie1-is-valueA' --cookie 'cookie1=valueA'
curl --cookie 'cookie1=valueA' 'http://localhost:8000/cookie-storage/assert-that-cookie1-is-valueA'
curl 'http://localhost:8000/cookie-storage/assert-that-cookie1-is-not-in-session'

View File

@ -1,9 +1,9 @@
curl 'http://localhost:8000/cookies/set-request-cookie1-valueA' --cookie 'cookie1=valueA'
curl --cookie 'cookie1=valueA' 'http://localhost:8000/cookies/set-request-cookie1-valueA'
curl 'http://localhost:8000/cookies/assert-that-cookie1-is-not-in-session'
curl 'http://localhost:8000/cookies/set-multiple-request-cookies' --cookie 'user1=Bob; user2=Bill; user3=Bruce'
curl --cookie 'user1=Bob; user2=Bill; user3=Bruce' 'http://localhost:8000/cookies/set-multiple-request-cookies'
curl 'http://localhost:8000/cookies/set-session-cookie2-valueA'
curl 'http://localhost:8000/cookies/assert-that-cookie2-is-valueA' --cookie 'cookie2=valueA'
curl 'http://localhost:8000/cookies/assert-that-cookie2-is-valueA-and-valueB' --cookie 'cookie2=valueB; cookie2=valueA'
curl 'http://localhost:8000/cookies/delete-cookie2' --cookie 'cookie2=valueA'
curl --cookie 'cookie2=valueA' 'http://localhost:8000/cookies/assert-that-cookie2-is-valueA'
curl --cookie 'cookie2=valueB; cookie2=valueA' 'http://localhost:8000/cookies/assert-that-cookie2-is-valueA-and-valueB'
curl --cookie 'cookie2=valueA' 'http://localhost:8000/cookies/delete-cookie2'
curl 'http://localhost:8000/cookies/assert-that-cookie2-is-not-in-session'
curl 'http://localhost:8000/cookies/set'

View File

@ -1,2 +1,2 @@
curl 'http://localhost:8000/delete' -X DELETE
curl -X DELETE 'http://localhost:8000/delete'

View File

@ -1 +1 @@
curl 'http://localhost:8000/expect' -H 'Expect: 100-continue' -H 'Content-Type:' --data 'data'
curl -H 'Expect: 100-continue' -H 'Content-Type:' --data 'data' 'http://localhost:8000/expect'

View File

@ -1 +1 @@
curl 'http://localhost:8000/follow-redirect' -L
curl -L 'http://localhost:8000/follow-redirect'

View File

@ -1,2 +1,2 @@
curl 'http://localhost:8000/form-params' --data 'param1=value1' --data 'param2=' --data 'param3=a%3Db' --data 'param4=a%253db' --data 'values[0]=0' --data 'values[1]=1'
curl 'http://localhost:8000/form-params' -H 'Content-Type: application/x-www-form-urlencoded' --data 'param1=value1&param2=&param3=a%3db&param4=a%253db&values[0]=0&values[1]=1'
curl --data 'param1=value1' --data 'param2=' --data 'param3=a%3Db' --data 'param4=a%253db' --data 'values[0]=0' --data 'values[1]=1' 'http://localhost:8000/form-params'
curl -H 'Content-Type: application/x-www-form-urlencoded' --data 'param1=value1&param2=&param3=a%3db&param4=a%253db&values[0]=0&values[1]=1' 'http://localhost:8000/form-params'

View File

@ -1,4 +1,4 @@
curl 'http://localhost:8000/graphql' -H 'Content-Type: application/json' --data '{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}'
curl 'http://localhost:8000/graphql' -H 'Content-Type: application/json' --data '{"query":"query Query {\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}'
curl 'http://localhost:8000/graphql' -H 'Content-Type: application/json' --data '{"query":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}","variables":"{\n \"id\": \"cGVvcGxlOjQ=\"\n}"}'
curl 'http://localhost:8000/graphql' -H 'Content-Type: application/json' --data '{"query":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}","variables":"{\n \"id\": \"cGVvcGxlOjQ=\"\n}"}'
curl -H 'Content-Type: application/json' --data '{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}' 'http://localhost:8000/graphql'
curl -H 'Content-Type: application/json' --data '{"query":"query Query {\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}' 'http://localhost:8000/graphql'
curl -H 'Content-Type: application/json' --data '{"query":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}","variables":"{\n \"id\": \"cGVvcGxlOjQ=\"\n}"}' 'http://localhost:8000/graphql'
curl -H 'Content-Type: application/json' --data '{"query":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}","variables":"{\n \"id\": \"cGVvcGxlOjQ=\"\n}"}' 'http://localhost:8000/graphql'

View File

@ -1 +1 @@
curl 'http://localhost:8000/head' --head
curl --head 'http://localhost:8000/head'

View File

@ -1,6 +1,6 @@
curl 'http://localhost:8000/hello'
curl 'http://localhost:8000/cookies/set-session-cookie2-valueA'
curl 'http://localhost:8000/follow-redirect' --cookie 'cookie2=valueA'
curl 'http://localhost:8000/follow-redirect' --cookie 'cookie2=valueA' -L
curl 'http://localhost:8000/captures' --cookie 'cookie2=valueA'
curl 'http://localhost:8000/assert-json' --cookie 'cookie2=valueA'
curl --cookie 'cookie2=valueA' 'http://localhost:8000/follow-redirect'
curl --cookie 'cookie2=valueA' -L 'http://localhost:8000/follow-redirect'
curl --cookie 'cookie2=valueA' 'http://localhost:8000/captures'
curl --cookie 'cookie2=valueA' 'http://localhost:8000/assert-json'

View File

@ -1,16 +1,16 @@
curl 'http://localhost:8000/methods/get'
curl 'http://localhost:8000/methods/head' --head
curl 'http://localhost:8000/methods/post' -X POST
curl 'http://localhost:8000/methods/put' -X PUT
curl 'http://localhost:8000/methods/delete' -X DELETE
curl 'http://localhost:8000/methods/connect' -X CONNECT
curl 'http://localhost:8000/methods/options' -X OPTIONS
curl 'http://localhost:8000/methods/trace' -X TRACE
curl 'http://localhost:8000/methods/patch' -X PATCH
curl 'http://localhost:8000/methods/link' -X LINK
curl 'http://localhost:8000/methods/unlink' -X UNLINK
curl 'http://localhost:8000/methods/purge' -X PURGE
curl 'http://localhost:8000/methods/lock' -X LOCK
curl 'http://localhost:8000/methods/unlock' -X UNLOCK
curl 'http://localhost:8000/methods/propfind' -X PROPFIND
curl 'http://localhost:8000/methods/view' -X VIEW
curl --head 'http://localhost:8000/methods/head'
curl -X POST 'http://localhost:8000/methods/post'
curl -X PUT 'http://localhost:8000/methods/put'
curl -X DELETE 'http://localhost:8000/methods/delete'
curl -X CONNECT 'http://localhost:8000/methods/connect'
curl -X OPTIONS 'http://localhost:8000/methods/options'
curl -X TRACE 'http://localhost:8000/methods/trace'
curl -X PATCH 'http://localhost:8000/methods/patch'
curl -X LINK 'http://localhost:8000/methods/link'
curl -X UNLINK 'http://localhost:8000/methods/unlink'
curl -X PURGE 'http://localhost:8000/methods/purge'
curl -X LOCK 'http://localhost:8000/methods/lock'
curl -X UNLOCK 'http://localhost:8000/methods/unlock'
curl -X PROPFIND 'http://localhost:8000/methods/propfind'
curl -X VIEW 'http://localhost:8000/methods/view'

View File

@ -1,4 +1,4 @@
curl 'http://localhost:8000/multilines/plain-text' -H 'Content-Type:' --data $'line1\nline2\nline3\n'
curl 'http://localhost:8000/multilines/json' -H 'Content-Type: application/json' --data $'{\n "foo": "bar"\n "baz": 123456\n}\n'
curl 'http://localhost:8000/multilines/xml' -H 'Content-Type: application/xml' --data $'<?xml version="1.0"?>\n<catalog>\n <book id="bk101">\n <author>Gambardella, Matthew</author>\n <title>XML Developer\'s Guide</title>\n <genre>Computer</genre>\n <price>44.95</price>\n <publish_date>2000-10-01</publish_date>\n <description>An in-depth look at creating applications\n with XML.</description>\n </book>\n</catalog>\n'
curl 'http://localhost:8000/multilines/graphql' -H 'Content-Type: application/json' --data '{"query":"{\n hero {\n name\n # Queries can have comments!\n friends {\n name\n }\n }\n}"}'
curl -H 'Content-Type:' --data $'line1\nline2\nline3\n' 'http://localhost:8000/multilines/plain-text'
curl -H 'Content-Type: application/json' --data $'{\n "foo": "bar"\n "baz": 123456\n}\n' 'http://localhost:8000/multilines/json'
curl -H 'Content-Type: application/xml' --data $'<?xml version="1.0"?>\n<catalog>\n <book id="bk101">\n <author>Gambardella, Matthew</author>\n <title>XML Developer\'s Guide</title>\n <genre>Computer</genre>\n <price>44.95</price>\n <publish_date>2000-10-01</publish_date>\n <description>An in-depth look at creating applications\n with XML.</description>\n </book>\n</catalog>\n' 'http://localhost:8000/multilines/xml'
curl -H 'Content-Type: application/json' --data '{"query":"{\n hero {\n name\n # Queries can have comments!\n friends {\n name\n }\n }\n}"}' 'http://localhost:8000/multilines/graphql'

View File

@ -1 +1 @@
curl 'http://localhost:8000/multipart-form-data' -F 'key1=value1' -F 'upload1=@tests_ok/data.txt;type=text/plain' -F 'upload2=@tests_ok/data.html;type=text/html' -F 'upload3=@tests_ok/data.txt;type=text/html'
curl -F 'key1=value1' -F 'upload1=@tests_ok/data.txt;type=text/plain' -F 'upload2=@tests_ok/data.html;type=text/html' -F 'upload3=@tests_ok/data.txt;type=text/html' 'http://localhost:8000/multipart-form-data'

View File

@ -1 +1 @@
curl 'http://localhost:8000/multipart-form-data' -F 'key1=value1' -F 'upload1=@tests_ok\data.txt;type=text/plain' -F 'upload2=@tests_ok\data.html;type=text/html' -F 'upload3=@tests_ok\data.txt;type=text/html'
curl -F 'key1=value1' -F 'upload1=@tests_ok\data.txt;type=text/plain' -F 'upload2=@tests_ok\data.html;type=text/html' -F 'upload3=@tests_ok\data.txt;type=text/html' 'http://localhost:8000/multipart-form-data'

View File

@ -1,21 +1,21 @@
curl 'http://localhost:8000/compressed/none' --compressed
curl --compressed 'http://localhost:8000/compressed/none'
curl 'http://localhost:8000/compressed/none'
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl --compressed 'http://localhost:8000/compressed/none'
curl --compressed 'http://localhost:8000/compressed/none'
curl --compressed 'http://localhost:8000/compressed/none'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/gzip'
curl --compressed 'http://localhost:8000/compressed/zlib'
curl --compressed 'http://localhost:8000/compressed/zlib'
curl --compressed 'http://localhost:8000/compressed/zlib'
curl --compressed 'http://localhost:8000/compressed/zlib'
# curl needs to be built with brotli support
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli_large' --compressed
curl 'http://localhost:8000/compressed/brotli_identity' --compressed
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli'
curl --compressed 'http://localhost:8000/compressed/brotli_large'
curl --compressed 'http://localhost:8000/compressed/brotli_identity'

View File

@ -1,3 +1,3 @@
curl 'http://localhost:8000/follow-redirect'
curl 'http://localhost:8000/follow-redirect'
curl 'http://localhost:8000/follow-redirect' -L
curl -L 'http://localhost:8000/follow-redirect'

View File

@ -14,7 +14,7 @@
* POST http://localhost:8000/jobs
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/jobs' -X POST
* curl -X POST 'http://localhost:8000/jobs'
*
> POST /jobs HTTP/1.1
> Host: localhost:8000
@ -222,7 +222,7 @@
* DELETE http://localhost:8000/jobs/~~~
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/jobs/~~~' -X DELETE
* curl -X DELETE 'http://localhost:8000/jobs/~~~'
*
> DELETE /jobs/~~~ HTTP/1.1
> Host: localhost:8000

View File

@ -1 +1 @@
curl 'http://localhost:8000/patch/file.txt' -X PATCH -H 'Host: www.example.com' -H 'Content-Type: application/example' -H 'If-Match: "e0023aa4e"'
curl -X PATCH -H 'Host: www.example.com' -H 'Content-Type: application/example' -H 'If-Match: "e0023aa4e"' 'http://localhost:8000/patch/file.txt'

View File

@ -1 +1 @@
curl 'http://localhost:8000/post-base64' -H 'Content-Type: application/octet-stream' --data $'\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21'
curl -H 'Content-Type: application/octet-stream' --data $'\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21' 'http://localhost:8000/post-base64'

View File

@ -1 +1 @@
curl 'http://localhost:8000/post-bytes' -H 'Content-Type: application/octet-stream' --data $'\x01\x02\x03'
curl -H 'Content-Type: application/octet-stream' --data $'\x01\x02\x03' 'http://localhost:8000/post-bytes'

View File

@ -1,2 +1,2 @@
curl 'http://localhost:8000/post-file' -H 'Content-Type:' --data '@tests_ok/data.bin'
curl 'http://localhost:8000/post-file' -H 'Content-Type:' --data '@tests_ok/post_file_with space'
curl -H 'Content-Type:' --data '@tests_ok/data.bin' 'http://localhost:8000/post-file'
curl -H 'Content-Type:' --data '@tests_ok/post_file_with space' 'http://localhost:8000/post-file'

View File

@ -1,2 +1,2 @@
curl 'http://localhost:8000/post-file' -H 'Content-Type:' --data '@tests_ok\data.bin'
curl 'http://localhost:8000/post-file' -H 'Content-Type:' --data '@tests_ok\post_file_with space'
curl -H 'Content-Type:' --data '@tests_ok\data.bin' 'http://localhost:8000/post-file'
curl -H 'Content-Type:' --data '@tests_ok\post_file_with space' 'http://localhost:8000/post-file'

View File

@ -1,8 +1,8 @@
curl 'http://localhost:8000/post-json' -H 'Content-Type: application/json' --data $'{\n "name": "Bob",\n "password": "&secret\\\\\'<>",\n "age": 30,\n "strict": true,\n "spacing": "\\n",\n "g_clef": "\\uD834\\uDD1E",\n "items": [true, "true", 1],\n "variable": "\\\\"\n}'
curl 'http://localhost:8000/post-json-array' -H 'Content-Type: application/json' --data '[1,2,3]'
curl 'http://localhost:8000/post-json-string' -H 'Content-Type: application/json' --data '"Hello"'
curl 'http://localhost:8000/post-json-number' -H 'Content-Type: application/json' --data '100'
curl 'http://localhost:8000/post-json-numbers' -H 'Content-Type: application/json' --data $'{\n "natural": 100,\n "negative": -1,\n "float": "3.333333333333333",\n "exponent": 100e100\n}'
curl 'http://localhost:8000/post-json-boolean' -H 'Content-Type: application/json' --data 'true'
curl -H 'Content-Type: application/json' --data $'{\n "name": "Bob",\n "password": "&secret\\\\\'<>",\n "age": 30,\n "strict": true,\n "spacing": "\\n",\n "g_clef": "\\uD834\\uDD1E",\n "items": [true, "true", 1],\n "variable": "\\\\"\n}' 'http://localhost:8000/post-json'
curl -H 'Content-Type: application/json' --data '[1,2,3]' 'http://localhost:8000/post-json-array'
curl -H 'Content-Type: application/json' --data '"Hello"' 'http://localhost:8000/post-json-string'
curl -H 'Content-Type: application/json' --data '100' 'http://localhost:8000/post-json-number'
curl -H 'Content-Type: application/json' --data $'{\n "natural": 100,\n "negative": -1,\n "float": "3.333333333333333",\n "exponent": 100e100\n}' 'http://localhost:8000/post-json-numbers'
curl -H 'Content-Type: application/json' --data 'true' 'http://localhost:8000/post-json-boolean'
curl 'http://localhost:8000/get-name'
curl 'http://localhost:8000/check_name' -H 'Content-Type: application/json' --data $'{\n "name": "Bob"\n}'
curl -H 'Content-Type: application/json' --data $'{\n "name": "Bob"\n}' 'http://localhost:8000/check_name'

View File

@ -1,3 +1,3 @@
curl 'http://localhost:8000/post-multilines' -H 'Content-Type:' --data $'name,age\nbob,10\nbill,22\n'
curl -H 'Content-Type:' --data $'name,age\nbob,10\nbill,22\n' 'http://localhost:8000/post-multilines'
curl 'http://localhost:8000/get-bob-age'
curl 'http://localhost:8000/post-multilines' -H 'Content-Type:' --data $'name,age\nbob,10\nbill,22\n'
curl -H 'Content-Type:' --data $'name,age\nbob,10\nbill,22\n' 'http://localhost:8000/post-multilines'

View File

@ -1 +1 @@
curl 'http://localhost:8000/proxy' --proxy 'localhost:8888'
curl --proxy 'localhost:8888' 'http://localhost:8000/proxy'

View File

@ -1 +1 @@
curl 'http://localhost:8000/put' -X PUT
curl -X PUT 'http://localhost:8000/put'

View File

@ -1,5 +1,5 @@
curl 'http://localhost:8000/redirected'
curl 'http://localhost:8000/redirect-absolute'
curl 'http://localhost:8000/redirect-absolute' -L
curl -L 'http://localhost:8000/redirect-absolute'
curl 'http://localhost:8000/redirect-relative'
curl 'http://localhost:8000/redirect-relative' -L
curl -L 'http://localhost:8000/redirect-relative'

View File

@ -1,3 +1,3 @@
curl 'http://foo.com:8000/hello' --resolve foo.com:8000:127.0.0.1 --resolve bar.com:8000:127.0.0.1 --resolve baz.com:8000:127.0.0.1
curl 'http://bar.com:8000/hello' --resolve foo.com:8000:127.0.0.1 --resolve bar.com:8000:127.0.0.1 --resolve baz.com:8000:127.0.0.1
curl 'http://baz.com:8000/hello' --resolve foo.com:8000:127.0.0.1 --resolve bar.com:8000:127.0.0.1 --resolve baz.com:8000:127.0.0.1
curl --resolve foo.com:8000:127.0.0.1 --resolve bar.com:8000:127.0.0.1 --resolve baz.com:8000:127.0.0.1 'http://foo.com:8000/hello'
curl --resolve foo.com:8000:127.0.0.1 --resolve bar.com:8000:127.0.0.1 --resolve baz.com:8000:127.0.0.1 'http://bar.com:8000/hello'
curl --resolve foo.com:8000:127.0.0.1 --resolve bar.com:8000:127.0.0.1 --resolve baz.com:8000:127.0.0.1 'http://baz.com:8000/hello'

View File

@ -14,7 +14,7 @@
* POST http://localhost:8000/jobs
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/jobs' -X POST
* curl -X POST 'http://localhost:8000/jobs'
*
> POST /jobs HTTP/1.1
> Host: localhost:8000
@ -202,7 +202,7 @@
* DELETE http://localhost:8000/jobs/~~~
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/jobs/~~~' -X DELETE
* curl -X DELETE 'http://localhost:8000/jobs/~~~'
*
> DELETE /jobs/~~~ HTTP/1.1
> Host: localhost:8000

View File

@ -1 +1 @@
curl 'http://localhost:8000/variables' -H 'Name: Jennifer' -H 'Age: 30' -H 'Height: 1.7' -H 'Female: true' -H 'Id: 123' -H 'A_Null: null' -H 'Country: Italy' -H 'Content-Type: application/json' --data $'{\n "name": "Jennifer",\n "age": 30,\n "height": 1.7,\n "female": true,\n "id": "123",\n "a_null": null,\n "country": "Italy"\n}'
curl -H 'Name: Jennifer' -H 'Age: 30' -H 'Height: 1.7' -H 'Female: true' -H 'Id: 123' -H 'A_Null: null' -H 'Country: Italy' -H 'Content-Type: application/json' --data $'{\n "name": "Jennifer",\n "age": 30,\n "height": 1.7,\n "female": true,\n "id": "123",\n "a_null": null,\n "country": "Italy"\n}' 'http://localhost:8000/variables'

View File

@ -1,6 +1,6 @@
curl 'http://localhost:8000/very-verbose/redirect' -L
curl 'http://localhost:8000/very-verbose/encoding/latin1' -L
curl 'http://localhost:8000/very-verbose/compressed/brotli' -H 'Accept-Encoding: brotli' -H 'Content-Type: application/json' --data $'{\n "foo": "bar",\n "baz": true\n}' -L
curl 'http://localhost:8000/very-verbose/cat' -L
curl 'http://localhost:8000/very-verbose/update-cat' -F 'cat=@tests_ok/cat.jpg;type=image/jpeg' -L
curl 'http://localhost:8000/very-verbose/done' -H 'x-foo: bar' -L
curl -L 'http://localhost:8000/very-verbose/redirect'
curl -L 'http://localhost:8000/very-verbose/encoding/latin1'
curl -H 'Accept-Encoding: brotli' -H 'Content-Type: application/json' --data $'{\n "foo": "bar",\n "baz": true\n}' -L 'http://localhost:8000/very-verbose/compressed/brotli'
curl -L 'http://localhost:8000/very-verbose/cat'
curl -F 'cat=@tests_ok/cat.jpg;type=image/jpeg' -L 'http://localhost:8000/very-verbose/update-cat'
curl -H 'x-foo: bar' -L 'http://localhost:8000/very-verbose/done'

View File

@ -14,7 +14,7 @@
* GET http://localhost:8000/very-verbose/redirect
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/very-verbose/redirect' -L
* curl -L 'http://localhost:8000/very-verbose/redirect'
*
** Trying 127.0.0.1:8000...
** Connected to localhost (127.0.0.1) port 8000 (#0)
@ -85,7 +85,7 @@
* GET http://localhost:8000/very-verbose/encoding/latin1
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/very-verbose/encoding/latin1' -L
* curl -L 'http://localhost:8000/very-verbose/encoding/latin1'
*
** Hostname localhost was found in DNS cache
** Trying 127.0.0.1:8000...
@ -123,7 +123,7 @@
* Implicit content-type=application/json
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/very-verbose/compressed/brotli' -H 'Accept-Encoding: brotli' -H 'Content-Type: application/json' --data $'{\n "foo": "bar",\n "baz": true\n}' -L
* curl -H 'Accept-Encoding: brotli' -H 'Content-Type: application/json' --data $'{\n "foo": "bar",\n "baz": true\n}' -L 'http://localhost:8000/very-verbose/compressed/brotli'
*
** Hostname localhost was found in DNS cache
** Trying 127.0.0.1:8000...
@ -166,7 +166,7 @@
* GET http://localhost:8000/very-verbose/cat
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/very-verbose/cat' -L
* curl -L 'http://localhost:8000/very-verbose/cat'
*
** Hostname localhost was found in DNS cache
** Trying 127.0.0.1:8000...
@ -205,7 +205,7 @@
* Implicit content-type=multipart/form-data
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/very-verbose/update-cat' -F 'cat=@tests_ok~cat.jpg;type=image/jpeg' -L
* curl -F 'cat=@tests_ok~cat.jpg;type=image/jpeg' -L 'http://localhost:8000/very-verbose/update-cat'
*
** Hostname localhost was found in DNS cache
** Trying 127.0.0.1:8000...
@ -244,7 +244,7 @@
* x-foo: bar
*
* Request can be run with the following curl command:
* curl 'http://localhost:8000/very-verbose/done' -H 'x-foo: bar' -L
* curl -H 'x-foo: bar' -L 'http://localhost:8000/very-verbose/done'
*
** Hostname localhost was found in DNS cache
** Trying 127.0.0.1:8000...

View File

@ -1,6 +1,6 @@
curl 'http://localhost:8000/very-verbose/redirect' -L
curl 'http://localhost:8000/very-verbose/encoding/latin1' -L
curl 'http://localhost:8000/very-verbose/compressed/brotli' -H 'Accept-Encoding: brotli' -H 'Content-Type: application/json' --data $'{\n "foo": "bar",\n "baz": true\n}' -L
curl 'http://localhost:8000/very-verbose/cat' -L
curl 'http://localhost:8000/very-verbose/update-cat' -F 'cat=@tests_ok\cat.jpg;type=image/jpeg' -L
curl 'http://localhost:8000/very-verbose/done' -H 'x-foo: bar' -L
curl -L 'http://localhost:8000/very-verbose/redirect'
curl -L 'http://localhost:8000/very-verbose/encoding/latin1'
curl -H 'Accept-Encoding: brotli' -H 'Content-Type: application/json' --data $'{\n "foo": "bar",\n "baz": true\n}' -L 'http://localhost:8000/very-verbose/compressed/brotli'
curl -L 'http://localhost:8000/very-verbose/cat'
curl -F 'cat=@tests_ok\cat.jpg;type=image/jpeg' -L 'http://localhost:8000/very-verbose/update-cat'
curl -H 'x-foo: bar' -L 'http://localhost:8000/very-verbose/done'

View File

@ -593,6 +593,10 @@ impl Client {
let mut arguments = vec!["curl".to_string()];
arguments.append(&mut request_spec.curl_args(context_dir));
// We extract the last part of the arguments (the url) to insert it
// after all the options
let url = arguments.pop().unwrap();
let cookies = all_cookies(&self.get_cookie_storage(), request_spec);
if !cookies.is_empty() {
arguments.push("--cookie".to_string());
@ -606,6 +610,7 @@ impl Client {
));
}
arguments.append(&mut options.curl_args());
arguments.push(url);
arguments.join(" ")
}
}
@ -705,6 +710,7 @@ pub fn decode_header(data: &[u8]) -> Option<String> {
}
}
/// Converts a list of [`String`] to a libcurl's list of strings.
fn to_list(items: &[String]) -> List {
let mut list = List::new();
items.iter().for_each(|l| list.append(l).unwrap());

View File

@ -69,6 +69,7 @@ impl Default for ClientOptions {
}
impl ClientOptions {
/// Returns the list of options for the curl command line equivalent to this [`ClientOptions`].
pub fn curl_args(&self) -> Vec<String> {
let mut arguments = vec![];

View File

@ -25,24 +25,7 @@ impl RequestSpec {
/// Returns this request as curl arguments.
/// It does not contain the requests cookies (they will be accessed from the client)
pub fn curl_args(&self, context_dir: &ContextDir) -> Vec<String> {
let querystring = if self.querystring.is_empty() {
"".to_string()
} else {
let params = self
.querystring
.iter()
.map(|p| p.curl_arg_escape())
.collect::<Vec<String>>();
params.join("&")
};
let url = if querystring.as_str() == "" {
self.url.to_string()
} else if self.url.to_string().contains('?') {
format!("{}&{}", self.url, querystring)
} else {
format!("{}?{}", self.url, querystring)
};
let mut arguments = vec![format!("'{}'", url)];
let mut arguments = vec![];
let data =
!self.multipart.is_empty() || !self.form.is_empty() || !self.body.bytes().is_empty();
@ -96,6 +79,26 @@ impl RequestSpec {
arguments.push("--data".to_string());
arguments.push(self.body.curl_arg(context_dir));
}
let querystring = if self.querystring.is_empty() {
"".to_string()
} else {
let params = self
.querystring
.iter()
.map(|p| p.curl_arg_escape())
.collect::<Vec<String>>();
params.join("&")
};
let url = if querystring.as_str() == "" {
self.url.to_string()
} else if self.url.to_string().contains('?') {
format!("{}&{}", self.url, querystring)
} else {
format!("{}?{}", self.url, querystring)
};
arguments.push(format!("'{}'", url));
arguments
}
}
@ -330,11 +333,11 @@ pub mod tests {
assert_eq!(
custom_http_request().curl_args(context_dir),
vec![
"'http://localhost/custom'".to_string(),
"-H".to_string(),
"'User-Agent: iPhone'".to_string(),
"-H".to_string(),
"'Foo: Bar'".to_string(),
"'http://localhost/custom'".to_string(),
]
);
assert_eq!(
@ -346,13 +349,13 @@ pub mod tests {
assert_eq!(
form_http_request().curl_args(context_dir),
vec![
"'http://localhost/form-params'".to_string(),
"-H".to_string(),
"'Content-Type: application/x-www-form-urlencoded'".to_string(),
"--data".to_string(),
"'param1=value1'".to_string(),
"--data".to_string(),
"'param2=a%20b'".to_string(),
"'http://localhost/form-params'".to_string(),
]
);
}

View File

@ -109,7 +109,7 @@ fn test_put() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/put' -X PUT".to_string()
"curl -X PUT 'http://localhost:8000/put'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -160,7 +160,7 @@ fn test_patch() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/patch/file.txt' -X PATCH -H 'Host: www.example.com' -H 'Content-Type: application/example' -H 'If-Match: \"e0023aa4e\"'".to_string()
"curl -X PATCH -H 'Host: www.example.com' -H 'Content-Type: application/example' -H 'If-Match: \"e0023aa4e\"' 'http://localhost:8000/patch/file.txt'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -212,7 +212,7 @@ fn test_custom_headers() {
assert!(options.curl_args().is_empty());
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/custom-headers' -H 'Fruit: Raspberry' -H 'Fruit: Apple' -H 'Fruit: Banana' -H 'Fruit: Grape' -H 'Color: Green'".to_string()
"curl -H 'Fruit: Raspberry' -H 'Fruit: Apple' -H 'Fruit: Banana' -H 'Fruit: Grape' -H 'Color: Green' 'http://localhost:8000/custom-headers'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -332,7 +332,7 @@ fn test_form_params() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/form-params' --data 'param1=value1' --data 'param2=' --data 'param3=a%3Db' --data 'param4=a%253db' --data 'values[0]=0' --data 'values[1]=1'".to_string()
"curl --data 'param1=value1' --data 'param2=' --data 'param3=a%3Db' --data 'param4=a%253db' --data 'values[0]=0' --data 'values[1]=1' 'http://localhost:8000/form-params'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -399,7 +399,7 @@ fn test_follow_location() {
assert_eq!(options.curl_args(), vec!["-L".to_string()]);
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/redirect-absolute' -L".to_string()
"curl -L 'http://localhost:8000/redirect-absolute'".to_string()
);
let calls = client
@ -461,7 +461,7 @@ fn test_max_redirect() {
let request_spec = default_get_request("http://localhost:8000/redirect/15");
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/redirect/15' -L --max-redirs 10".to_string()
"curl -L --max-redirs 10 'http://localhost:8000/redirect/15'".to_string()
);
let error = client
.execute_with_redirect(&request_spec, &options, &logger)
@ -472,7 +472,7 @@ fn test_max_redirect() {
let request_spec = default_get_request("http://localhost:8000/redirect/8");
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/redirect/8' -L --max-redirs 10".to_string()
"curl -L --max-redirs 10 'http://localhost:8000/redirect/8'".to_string()
);
let calls = client
.execute_with_redirect(&request_spec, &options, &logger)
@ -529,7 +529,7 @@ fn test_multipart_form_data() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/multipart-form-data' -F 'key1=value1' -F 'upload1=@data.txt;type=text/plain' -F 'upload2=@data.html;type=text/html' -F 'upload3=@data.txt;type=text/html'".to_string()
"curl -F 'key1=value1' -F 'upload1=@data.txt;type=text/plain' -F 'upload2=@data.html;type=text/html' -F 'upload3=@data.txt;type=text/html' 'http://localhost:8000/multipart-form-data'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -571,7 +571,7 @@ fn test_post_bytes() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/post-base64' -H 'Content-Type: application/octet-stream' --data $'\\x48\\x65\\x6c\\x6c\\x6f\\x20\\x57\\x6f\\x72\\x6c\\x64\\x21'".to_string()
"curl -H 'Content-Type: application/octet-stream' --data $'\\x48\\x65\\x6c\\x6c\\x6f\\x20\\x57\\x6f\\x72\\x6c\\x64\\x21' 'http://localhost:8000/post-base64'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
assert!(request.headers.contains(&Header {
@ -607,7 +607,7 @@ fn test_expect() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/expect' -H 'Expect: 100-continue' -H 'Content-Type:' --data 'data'".to_string()
"curl -H 'Expect: 100-continue' -H 'Content-Type:' --data 'data' 'http://localhost:8000/expect'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -642,7 +642,7 @@ fn test_basic_authentication() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/basic-authentication' --user 'bob@email.com:secret'"
"curl --user 'bob@email.com:secret' 'http://localhost:8000/basic-authentication'"
.to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -890,7 +890,7 @@ fn test_connect_timeout() {
let request_spec = default_get_request("http://10.0.0.0");
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://10.0.0.0' --connect-timeout 1".to_string()
"curl --connect-timeout 1 'http://10.0.0.0'".to_string()
);
let error = client
.execute(&request_spec, &options, &logger)
@ -945,7 +945,7 @@ fn test_cookie() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/cookies/set-request-cookie1-valueA' --cookie 'cookie1=valueA'"
"curl --cookie 'cookie1=valueA' 'http://localhost:8000/cookies/set-request-cookie1-valueA'"
.to_string()
);
@ -1006,7 +1006,7 @@ fn test_multiple_request_cookies() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/cookies/set-multiple-request-cookies' --cookie 'user1=Bob; user2=Bill; user3=Bruce'".to_string()
"curl --cookie 'user1=Bob; user2=Bill; user3=Bruce' 'http://localhost:8000/cookies/set-multiple-request-cookies'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -1072,7 +1072,7 @@ fn test_cookie_file() {
default_get_request("http://localhost:8000/cookies/assert-that-cookie2-is-valueA");
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/cookies/assert-that-cookie2-is-valueA' --cookie tests/cookies.txt".to_string()
"curl --cookie tests/cookies.txt 'http://localhost:8000/cookies/assert-that-cookie2-is-valueA'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -1106,7 +1106,7 @@ fn test_proxy() {
let request_spec = default_get_request("http://localhost:8000/proxy");
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/proxy' --proxy 'localhost:8888'".to_string()
"curl --proxy 'localhost:8888' 'http://localhost:8000/proxy'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
assert_eq!(request.url, "http://localhost:8000/proxy");
@ -1128,7 +1128,7 @@ fn test_insecure() {
let request_spec = default_get_request("https://localhost:8001/hello");
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'https://localhost:8001/hello' --insecure".to_string()
"curl --insecure 'https://localhost:8001/hello'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();
@ -1157,7 +1157,7 @@ fn test_head() {
};
assert_eq!(
client.curl_command_line(&request_spec, &context_dir, &options),
"curl 'http://localhost:8000/head' --head".to_string()
"curl --head 'http://localhost:8000/head'".to_string()
);
let (request, response) = client.execute(&request_spec, &options, &logger).unwrap();