From ec30da5b057e3e732bdded370aee54e66a876d16 Mon Sep 17 00:00:00 2001 From: jcamiel Date: Fri, 9 Dec 2022 15:00:12 +0100 Subject: [PATCH] Normalize curl command line debug with the url at the end. --- integration/ssl/cacert.curl | 4 +- integration/ssl/insecure.curl | 4 +- integration/ssl/options.curl | 6 +-- .../tests_ok/basic_authentication.curl | 2 +- .../basic_authentication_per_request.curl | 4 +- integration/tests_ok/bom.curl | 2 +- integration/tests_ok/bom.windows.curl | 2 +- integration/tests_ok/compressed.curl | 36 ++++++++-------- integration/tests_ok/cookie_file.curl | 2 +- integration/tests_ok/cookie_storage.curl | 2 +- integration/tests_ok/cookies.curl | 10 ++--- integration/tests_ok/delete.curl | 2 +- integration/tests_ok/expect.curl | 2 +- integration/tests_ok/follow_redirect.curl | 2 +- integration/tests_ok/form_params.curl | 4 +- integration/tests_ok/graphql.curl | 8 ++-- integration/tests_ok/head.curl | 2 +- integration/tests_ok/json_output.curl | 8 ++-- integration/tests_ok/method.curl | 30 ++++++------- integration/tests_ok/multilines.curl | 8 ++-- integration/tests_ok/multipart_form_data.curl | 2 +- .../tests_ok/multipart_form_data.windows.curl | 2 +- integration/tests_ok/option_compressed.curl | 36 ++++++++-------- .../tests_ok/option_follow_redirect.curl | 2 +- integration/tests_ok/option_retry.err.pattern | 4 +- integration/tests_ok/patch.curl | 2 +- integration/tests_ok/post_base64.curl | 2 +- integration/tests_ok/post_bytes.curl | 2 +- integration/tests_ok/post_file.curl | 4 +- integration/tests_ok/post_file.windows.curl | 4 +- integration/tests_ok/post_json.curl | 14 +++--- integration/tests_ok/post_multilines.curl | 4 +- integration/tests_ok/proxy.curl | 2 +- integration/tests_ok/put.curl | 2 +- integration/tests_ok/redirect.curl | 4 +- integration/tests_ok/resolve.curl | 6 +-- integration/tests_ok/retry.err.pattern | 4 +- integration/tests_ok/variables.curl | 2 +- integration/tests_ok/very_verbose.curl | 12 +++--- integration/tests_ok/very_verbose.err.pattern | 12 +++--- .../tests_ok/very_verbose.windows.curl | 12 +++--- packages/hurl/src/http/client.rs | 6 +++ packages/hurl/src/http/options.rs | 1 + .../hurl/src/http/request_spec_curl_args.rs | 43 ++++++++++--------- packages/hurl/tests/libcurl.rs | 36 ++++++++-------- 45 files changed, 185 insertions(+), 175 deletions(-) diff --git a/integration/ssl/cacert.curl b/integration/ssl/cacert.curl index 2dee5f6b8..df1692ff1 100644 --- a/integration/ssl/cacert.curl +++ b/integration/ssl/cacert.curl @@ -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' diff --git a/integration/ssl/insecure.curl b/integration/ssl/insecure.curl index de4f6f22e..4fd4b08d9 100644 --- a/integration/ssl/insecure.curl +++ b/integration/ssl/insecure.curl @@ -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' diff --git a/integration/ssl/options.curl b/integration/ssl/options.curl index 8a9d10912..0d8fb32a3 100644 --- a/integration/ssl/options.curl +++ b/integration/ssl/options.curl @@ -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' diff --git a/integration/tests_ok/basic_authentication.curl b/integration/tests_ok/basic_authentication.curl index 81c455204..b2b4e0602 100644 --- a/integration/tests_ok/basic_authentication.curl +++ b/integration/tests_ok/basic_authentication.curl @@ -1 +1 @@ -curl 'http://localhost:8000/basic-authentication' --user 'bob@email.com:secret' +curl --user 'bob@email.com:secret' 'http://localhost:8000/basic-authentication' diff --git a/integration/tests_ok/basic_authentication_per_request.curl b/integration/tests_ok/basic_authentication_per_request.curl index 9de54941b..aa7dc8e70 100644 --- a/integration/tests_ok/basic_authentication_per_request.curl +++ b/integration/tests_ok/basic_authentication_per_request.curl @@ -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' diff --git a/integration/tests_ok/bom.curl b/integration/tests_ok/bom.curl index 539a4c6b7..e79a4d9d3 100644 --- a/integration/tests_ok/bom.curl +++ b/integration/tests_ok/bom.curl @@ -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' diff --git a/integration/tests_ok/bom.windows.curl b/integration/tests_ok/bom.windows.curl index e2204704f..9a1e0a489 100644 --- a/integration/tests_ok/bom.windows.curl +++ b/integration/tests_ok/bom.windows.curl @@ -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' diff --git a/integration/tests_ok/compressed.curl b/integration/tests_ok/compressed.curl index 07964b61e..22bb93cd8 100644 --- a/integration/tests_ok/compressed.curl +++ b/integration/tests_ok/compressed.curl @@ -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' diff --git a/integration/tests_ok/cookie_file.curl b/integration/tests_ok/cookie_file.curl index f6d438b5c..659ce3146 100644 --- a/integration/tests_ok/cookie_file.curl +++ b/integration/tests_ok/cookie_file.curl @@ -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' diff --git a/integration/tests_ok/cookie_storage.curl b/integration/tests_ok/cookie_storage.curl index 0d6e528e9..88a9addc6 100644 --- a/integration/tests_ok/cookie_storage.curl +++ b/integration/tests_ok/cookie_storage.curl @@ -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' diff --git a/integration/tests_ok/cookies.curl b/integration/tests_ok/cookies.curl index 69ddb20df..3ff487f3c 100644 --- a/integration/tests_ok/cookies.curl +++ b/integration/tests_ok/cookies.curl @@ -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' diff --git a/integration/tests_ok/delete.curl b/integration/tests_ok/delete.curl index 066fe917d..cbeec5836 100644 --- a/integration/tests_ok/delete.curl +++ b/integration/tests_ok/delete.curl @@ -1,2 +1,2 @@ -curl 'http://localhost:8000/delete' -X DELETE +curl -X DELETE 'http://localhost:8000/delete' diff --git a/integration/tests_ok/expect.curl b/integration/tests_ok/expect.curl index 22c74c0d4..a47523819 100644 --- a/integration/tests_ok/expect.curl +++ b/integration/tests_ok/expect.curl @@ -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' diff --git a/integration/tests_ok/follow_redirect.curl b/integration/tests_ok/follow_redirect.curl index 8329f0321..a4db12596 100644 --- a/integration/tests_ok/follow_redirect.curl +++ b/integration/tests_ok/follow_redirect.curl @@ -1 +1 @@ -curl 'http://localhost:8000/follow-redirect' -L +curl -L 'http://localhost:8000/follow-redirect' diff --git a/integration/tests_ok/form_params.curl b/integration/tests_ok/form_params.curl index 1be0c7606..281266e2d 100644 --- a/integration/tests_ok/form_params.curl +++ b/integration/tests_ok/form_params.curl @@ -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¶m2=¶m3=a%3db¶m4=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¶m2=¶m3=a%3db¶m4=a%253db&values[0]=0&values[1]=1' 'http://localhost:8000/form-params' diff --git a/integration/tests_ok/graphql.curl b/integration/tests_ok/graphql.curl index c81f8a7dc..b92396703 100644 --- a/integration/tests_ok/graphql.curl +++ b/integration/tests_ok/graphql.curl @@ -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' diff --git a/integration/tests_ok/head.curl b/integration/tests_ok/head.curl index 979946cc1..5b90cc740 100644 --- a/integration/tests_ok/head.curl +++ b/integration/tests_ok/head.curl @@ -1 +1 @@ -curl 'http://localhost:8000/head' --head +curl --head 'http://localhost:8000/head' diff --git a/integration/tests_ok/json_output.curl b/integration/tests_ok/json_output.curl index 0258bf2d7..34fe6333e 100644 --- a/integration/tests_ok/json_output.curl +++ b/integration/tests_ok/json_output.curl @@ -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' diff --git a/integration/tests_ok/method.curl b/integration/tests_ok/method.curl index 7296d522b..5abfcca90 100644 --- a/integration/tests_ok/method.curl +++ b/integration/tests_ok/method.curl @@ -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' diff --git a/integration/tests_ok/multilines.curl b/integration/tests_ok/multilines.curl index e27cb3e75..9930040a1 100644 --- a/integration/tests_ok/multilines.curl +++ b/integration/tests_ok/multilines.curl @@ -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 $'\n\n \n Gambardella, Matthew\n XML Developer\'s Guide\n Computer\n 44.95\n 2000-10-01\n An in-depth look at creating applications\n with XML.\n \n\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 $'\n\n \n Gambardella, Matthew\n XML Developer\'s Guide\n Computer\n 44.95\n 2000-10-01\n An in-depth look at creating applications\n with XML.\n \n\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' diff --git a/integration/tests_ok/multipart_form_data.curl b/integration/tests_ok/multipart_form_data.curl index 4bdc0a271..1cddc0eaa 100644 --- a/integration/tests_ok/multipart_form_data.curl +++ b/integration/tests_ok/multipart_form_data.curl @@ -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' diff --git a/integration/tests_ok/multipart_form_data.windows.curl b/integration/tests_ok/multipart_form_data.windows.curl index c2481a1ae..4930ae66b 100644 --- a/integration/tests_ok/multipart_form_data.windows.curl +++ b/integration/tests_ok/multipart_form_data.windows.curl @@ -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' diff --git a/integration/tests_ok/option_compressed.curl b/integration/tests_ok/option_compressed.curl index 7f395940c..bcb08eefe 100644 --- a/integration/tests_ok/option_compressed.curl +++ b/integration/tests_ok/option_compressed.curl @@ -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' diff --git a/integration/tests_ok/option_follow_redirect.curl b/integration/tests_ok/option_follow_redirect.curl index 31e75d250..83705bb2b 100644 --- a/integration/tests_ok/option_follow_redirect.curl +++ b/integration/tests_ok/option_follow_redirect.curl @@ -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' diff --git a/integration/tests_ok/option_retry.err.pattern b/integration/tests_ok/option_retry.err.pattern index d68476252..bbed71d92 100644 --- a/integration/tests_ok/option_retry.err.pattern +++ b/integration/tests_ok/option_retry.err.pattern @@ -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 diff --git a/integration/tests_ok/patch.curl b/integration/tests_ok/patch.curl index 95e4531e8..536a20df4 100644 --- a/integration/tests_ok/patch.curl +++ b/integration/tests_ok/patch.curl @@ -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' diff --git a/integration/tests_ok/post_base64.curl b/integration/tests_ok/post_base64.curl index 7686915cc..45fe161bc 100644 --- a/integration/tests_ok/post_base64.curl +++ b/integration/tests_ok/post_base64.curl @@ -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' diff --git a/integration/tests_ok/post_bytes.curl b/integration/tests_ok/post_bytes.curl index 2fec97a02..64c37aa98 100644 --- a/integration/tests_ok/post_bytes.curl +++ b/integration/tests_ok/post_bytes.curl @@ -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' diff --git a/integration/tests_ok/post_file.curl b/integration/tests_ok/post_file.curl index 20c8dfdf2..10d6f42cb 100644 --- a/integration/tests_ok/post_file.curl +++ b/integration/tests_ok/post_file.curl @@ -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' diff --git a/integration/tests_ok/post_file.windows.curl b/integration/tests_ok/post_file.windows.curl index 6e8a584f0..710d28545 100644 --- a/integration/tests_ok/post_file.windows.curl +++ b/integration/tests_ok/post_file.windows.curl @@ -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' diff --git a/integration/tests_ok/post_json.curl b/integration/tests_ok/post_json.curl index c3e7fb1c6..f8972031b 100644 --- a/integration/tests_ok/post_json.curl +++ b/integration/tests_ok/post_json.curl @@ -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}' \ No newline at end of file +curl -H 'Content-Type: application/json' --data $'{\n "name": "Bob"\n}' 'http://localhost:8000/check_name' \ No newline at end of file diff --git a/integration/tests_ok/post_multilines.curl b/integration/tests_ok/post_multilines.curl index 4acd95a5e..742762386 100644 --- a/integration/tests_ok/post_multilines.curl +++ b/integration/tests_ok/post_multilines.curl @@ -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' diff --git a/integration/tests_ok/proxy.curl b/integration/tests_ok/proxy.curl index a82276b02..72f275e54 100644 --- a/integration/tests_ok/proxy.curl +++ b/integration/tests_ok/proxy.curl @@ -1 +1 @@ -curl 'http://localhost:8000/proxy' --proxy 'localhost:8888' +curl --proxy 'localhost:8888' 'http://localhost:8000/proxy' diff --git a/integration/tests_ok/put.curl b/integration/tests_ok/put.curl index a33f1c9d0..04d01f83f 100644 --- a/integration/tests_ok/put.curl +++ b/integration/tests_ok/put.curl @@ -1 +1 @@ -curl 'http://localhost:8000/put' -X PUT +curl -X PUT 'http://localhost:8000/put' diff --git a/integration/tests_ok/redirect.curl b/integration/tests_ok/redirect.curl index 1e9cf5f46..e7c5f8df7 100644 --- a/integration/tests_ok/redirect.curl +++ b/integration/tests_ok/redirect.curl @@ -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' diff --git a/integration/tests_ok/resolve.curl b/integration/tests_ok/resolve.curl index aaea26368..21bc52ed5 100644 --- a/integration/tests_ok/resolve.curl +++ b/integration/tests_ok/resolve.curl @@ -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 \ No newline at end of file +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' \ No newline at end of file diff --git a/integration/tests_ok/retry.err.pattern b/integration/tests_ok/retry.err.pattern index 44a5207ee..15cab10fe 100644 --- a/integration/tests_ok/retry.err.pattern +++ b/integration/tests_ok/retry.err.pattern @@ -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 diff --git a/integration/tests_ok/variables.curl b/integration/tests_ok/variables.curl index 8ec683251..1a3765b2f 100644 --- a/integration/tests_ok/variables.curl +++ b/integration/tests_ok/variables.curl @@ -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' diff --git a/integration/tests_ok/very_verbose.curl b/integration/tests_ok/very_verbose.curl index ed8b3362e..b7b6040ef 100644 --- a/integration/tests_ok/very_verbose.curl +++ b/integration/tests_ok/very_verbose.curl @@ -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 \ No newline at end of file +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' \ No newline at end of file diff --git a/integration/tests_ok/very_verbose.err.pattern b/integration/tests_ok/very_verbose.err.pattern index 41000d687..be2a37617 100644 --- a/integration/tests_ok/very_verbose.err.pattern +++ b/integration/tests_ok/very_verbose.err.pattern @@ -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... diff --git a/integration/tests_ok/very_verbose.windows.curl b/integration/tests_ok/very_verbose.windows.curl index 3c15750d4..45b7b6afa 100644 --- a/integration/tests_ok/very_verbose.windows.curl +++ b/integration/tests_ok/very_verbose.windows.curl @@ -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 \ No newline at end of file +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' \ No newline at end of file diff --git a/packages/hurl/src/http/client.rs b/packages/hurl/src/http/client.rs index 19709993d..b14d0c3fe 100644 --- a/packages/hurl/src/http/client.rs +++ b/packages/hurl/src/http/client.rs @@ -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 { } } +/// 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()); diff --git a/packages/hurl/src/http/options.rs b/packages/hurl/src/http/options.rs index c4c6487d0..d86db7361 100644 --- a/packages/hurl/src/http/options.rs +++ b/packages/hurl/src/http/options.rs @@ -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 { let mut arguments = vec![]; diff --git a/packages/hurl/src/http/request_spec_curl_args.rs b/packages/hurl/src/http/request_spec_curl_args.rs index 122b2672b..f71ea9bf8 100644 --- a/packages/hurl/src/http/request_spec_curl_args.rs +++ b/packages/hurl/src/http/request_spec_curl_args.rs @@ -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 { - let querystring = if self.querystring.is_empty() { - "".to_string() - } else { - let params = self - .querystring - .iter() - .map(|p| p.curl_arg_escape()) - .collect::>(); - 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::>(); + 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(), ] ); } diff --git a/packages/hurl/tests/libcurl.rs b/packages/hurl/tests/libcurl.rs index 6e448c1a7..24aea6d22 100644 --- a/packages/hurl/tests/libcurl.rs +++ b/packages/hurl/tests/libcurl.rs @@ -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();