Special characters like @ and & in cURL POST data

前端 未结 6 1239
旧时难觅i
旧时难觅i 2020-12-07 18:52

How do I include special characters like @ and & in the cURL POST data? I\'m trying to pass a name and password like:

curl -d name=john passwd=@31&3*         


        
相关标签:
6条回答
  • 2020-12-07 19:06

    Just found another solutions worked for me. You can use '\' sign before your one special.

    passwd=\@31\&3*J
    
    0 讨论(0)
  • 2020-12-07 19:09

    Try this:

    export CURLNAME="john:@31&3*J"
    curl -d -u "${CURLNAME}" https://www.example.com
    
    0 讨论(0)
  • 2020-12-07 19:15

    Double quote (" ") the entire URL .It works.

    curl "http://www.mysite.com?name=john&passwd=@31&3*J"
    
    0 讨论(0)
  • 2020-12-07 19:18

    I did this

    ~]$ export A=g
    
    ~]$ export B=!
    
    ~]$ export C=nger
    
    
       curl http://<>USERNAME<>1:$A$B$C@<>URL<>/<>PATH<>/
    
    0 讨论(0)
  • 2020-12-07 19:21

    cURL > 7.18.0 has an option --data-urlencode which solves this problem. Using this, I can simply send a POST request as

    curl -d name=john --data-urlencode passwd=@31&3*J https://www.mysite.com
    
    0 讨论(0)
  • 2020-12-07 19:21

    How about using the entity codes...

    @ = %40

    & = %26

    So, you would have:

    curl -d 'name=john&passwd=%4031%263*J' https://www.mysite.com

    0 讨论(0)
提交回复
热议问题