クエリパラメータにスペースがあるURLがあります。カールのように使いたい
curl -G "http://localhost:30001/data?zip=47401&utc_begin=2013-8-1 00:00:00&utc_end=2013-8-2 00:00:00&country_code=USA"
与えられた
Malformed Request-Line
私が理解したのは、クエリパラメータにスペースがあるため、o / pが発生することです。
カールコマンドにURLを提供する前にURLを自動的にエンコードする方法はありますか?
ベストアンサー1
curl
内部URLエンコーディングのサポート--data-urlencode
:
$ curl -G -v "http://localhost:30001/data" --data-urlencode "msg=hello world" --data-urlencode "msg2=hello world2"
-G
また、データをURLに追加する必要があります。
トレースヘッダ
> GET /data?msg=hello%20world&msg2=hello%20world2 HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu)
> Host: localhost
> Accept: */*