带卷的二进制数据发布

所以基本上,我正在尝试写一系列的脚本与点网核互动。我一直在分析流量,现在可以登录和做一些基本的任务。但是,我从未用 curl 处理过二进制文件上传。有人愿意帮我看看这个吗?下面是这个请求的解剖:

Http://pastebin.com/qu8zemaq

以下是我目前为止对卷发的看法:

Http://pastebin.com/lg2ubfzg

编辑: 对于懒人-

获得文件的长度并以 LENGTH 格式存储
STUFF 只是带参数的请求 URL 的复制/粘贴,减去 URL 本身。

curl -L --cookie ~/.cms --data-binary "@background.jpg" \
--header "Content-Length: $LENGTH" \
--header "Content-Disposition: form-data" \
--header "name=\"RadFileExplorer1_upload1file0\"" \
--header "Content-Type: image/jpg" \
--header "Filename=\"background.jpg\"" \
--data $STUFF \
--referer "Kept-Secret" \
"Kept-Secret"
221948 次浏览

你不需要 ——标题“ Content-Llength: $LENTH”

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

请注意,GET 请求不支持内容体 广泛的

还要记住,POST 请求有两种不同的编码模式,这是第一种形式:

$ 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::

你可能会这样要求:

-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.