发送/ post xml文件使用curl命令行 [英] send/post xml file using curl command line
问题描述
如何使用curl从本地服务器发送/发布xml文件 http:// localhost:8080 命令行?
我应该使用什么命令?
连接到您的其他哈德森问题使用他们提供的命令。
$ curl -X POST -d'< run>< log encoding =hexBinary> 4142430A< / log> ;< result> 0< / result>< duration> 2000< / duration>< / run>'\
http:// user:pass @ myhost / hudson / job / _jobName_ / postBuildResult
您需要更改一点才能从文件读取:
$ curl -X POST -d @myfilename http:// user:pass @ myhost / hudson / job / _jobName_ / postBuildResult
阅读联机帮助页。遵循-d参数的抽象。
>(HTTP)将
POST请求中的指定数据发送到HTTP服务器,在
中,与浏览器在
a用户填写HTML表单时相同,
按提交按钮。这将
导致curl使用内容类型
application / x-www-form-urlencoded将数据传递到
服务器。
与-F / - 形式比较。
-d / - data与--data-ascii相同。要发布数据纯二进制,你应该
而不是使用--data-binary选项。
要对表单
的值进行URL编码,您可以使用--data-urlencode。
如果使用这些选项中的任何一个
比同一命令行上一次,
指定的数据将
与分离
& -symbol合并在一起。因此,使用-d name = daniel
-d skill = lousy将生成一个看起来像
'name = daniel& skill = lousy'的post chunk。
如果你使用字母
@启动数据,其余的应该是一个文件名到
读取数据,或者 - 如果你想要
curl读取数据从stdin。文件的
内容必须已经是
URL编码。也可以指定多个文件
。因此,从名为foobar的文件
中发布数据将使用
--data @foobar。
How can I send/post an xml file to a local server http://localhost:8080 using curl from the command line?
What command should I use?
If that question is connected to your other Hudson questions use the command they provide.
$ curl -X POST -d '<run><log encoding="hexBinary">4142430A</log><result>0</result><duration>2000</duration></run>' \
http://user:pass@myhost/hudson/job/_jobName_/postBuildResult
You need to change it a little bit to read from a file:
$ curl -X POST -d @myfilename http://user:pass@myhost/hudson/job/_jobName_/postBuildResult
Read the manpage. following an abstract for -d Parameter.
-d/--data
(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F/--form.
-d/--data is the same as --data-ascii. To post data purely binary, you should instead use the --data-binary option. To URL-encode the value of a form field you may use --data-urlencode.
If any of these options is used more than once on the same command line, the data pieces specified will be merged together with a separating &-symbol. Thus, using '-d name=daniel -d skill=lousy' would generate a post chunk that looks like 'name=daniel&skill=lousy'.
If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. The contents of the file must already be URL-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar.
这篇关于发送/ post xml文件使用curl命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!