【问题标题】:Use curl with a string input parameter in the url在 url 中使用带有字符串输入参数的 curl
【发布时间】:2018-03-14 02:28:39
【问题描述】:

我想将curl 用于GET 请求,但网址的格式为:

localhost:<port>/getter?key=This is a sentence.,表示key是端点中的输入参数。

如果我在请求中使用POSTMAN,那么带有空格的格式绝对没问题。

当我使用curl 时,我很难给出正确的格式。当我们有空格时,我尝试使用百分比符号,但我无法弄清楚。

【问题讨论】:

    标签: macos curl postman


    【解决方案1】:

    替换:

    localhost:<port>/getter?key=This is a sentence
    

    通过

    'http://localhost:<port>/getter?key=This%20is%20a%20sentence'
    

    注意%20

    如果你想要一个命令行为你做这件事:

    echo "/getter?key=This is a sentence" |
        perl -MURI::Escape -lne 'print uri_escape($_);'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多