Binary Data Posting with curl

前端 未结 1 1963
南笙
南笙 2020-12-08 13:20

So basically, I\'m trying to write a series of scripts to interact with Dot Net Nuke. I\'ve been analysing the traffic and can now login and do some basic tasks. However, I\

相关标签:
1条回答
  • 2020-12-08 13:33

    You don't need --header "Content-Length: $LENGTH".

    curl --request POST --data-binary "@template_entry.xml" $URL
    

    Note that GET request does not support content body widely.

    Also remember that POST request have 2 different coding schema. This is first form:

      $ nc -l -p 6666 &
      $ curl  --request POST --data-binary "@README" http://localhost:6666
    
    POST / HTTP/1.1
    User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
    Host: localhost:6666
    Accept: */*
    Content-Length: 9309
    Content-Type: application/x-www-form-urlencoded
    Expect: 100-continue
    
    .. -*- mode: rst; coding: cp1251; fill-column: 80 -*-
    .. rst2html.py README README.html
    .. contents::
    

    You probably request this:

    -F/--form name=content
               (HTTP) This lets curl emulate a filled-in form in
                  which a user has pressed the submit button. This
                  causes curl to POST data using the Content- Type
                  multipart/form-data according to RFC2388. This
                  enables uploading of binary files etc. To force the
                  'content' part to be a file, prefix the file name
                  with an @ sign. To just get the content part from a
                  file, prefix the file name with the symbol <. The
                  difference between @ and < is then that @ makes a
                  file get attached in the post as a file upload,
                  while the < makes a text field and just get the
                  contents for that text field from a file.
    
    0 讨论(0)
提交回复
热议问题