jpk*_*pka 6 linux post curl soap command-line-interface
我尝试添加Content-ID:只要一些其他自定义标头,仅使用curl和命令行(标头不应来自文件),并且对于同一请求中的每个附件,它们应该不同。但目前我只能指定每个文件的内容类型(已记录)。我没有找到任何适合我的任务的文档示例。
我用类似的东西:
curl -X POST --form "file=@test1.txt" --form "file=@test2.jpg" http://host:port
Run Code Online (Sandbox Code Playgroud)
结果如下(用wireshark重建)。默认情况下没有TEST单词(见下文)。
POST / HTTP/1.1
Host: host:port
User-Agent: curl/7.52.1
Accept: */*
Content-Length: 408
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------d7a9fdc4812ebc3b
[SERVER REPLY:] HTTP/1.1 100 Continue
--------------------------d7a9fdc4812ebc3b
Content-Disposition: form-data; name="file"; filename="test1.txt"
Content-Type: text/plain
TEST <-- This is from _curl_ C code bruteforce. Here should be "Content-ID:from_command_line_for_file_1"
CONTENTS_OF_test1.txt
line2
line3
--------------------------d7a9fdc4812ebc3b
Content-Disposition: form-data; name="file"; filename="test2.jpg"
Content-Type: image/jpeg
TEST <-- This is from _curl_ C code bruteforce. Here should be "Content-ID:from_command_line_for_file_2"
CONTENTS_OF_test2.jpg
line2
line3
--------------------------d7a9fdc4812ebc3b--
Run Code Online (Sandbox Code Playgroud)
为了看看是否可以使用curl,我深入研究了它的源代码。在“formdata.c”行 ~1290 处有我的确切任务的代码。但如何激活这个代码呢?为了确认此代码是否确实适用于每个文件处理,我对其进行了暴力测试,并且它有效(请参阅上面的“测试”字样)。
curList = file->contentheader;
while(curList) {
/* Process the additional headers specified for this form */
result = AddFormDataf(&form, &size, "\r\n%s", curList->data);
if(result)
break;
curList = curList->next;
}
// my bruteforce added line for test:
result = AddFormDataf(&form, &size, "\r\n%s", "TEST");
Run Code Online (Sandbox Code Playgroud)
所以看起来我的任务已经得到了curl的支持,但是如何使用它,以及我应该通过命令行传递哪些参数(不使用/来自某些文件)?
mancurl并没有对此提出太多建议,但它说“请参阅手册中的更多示例和详细信息”,但我找不到有用的东西。
卷曲7.52.1
谢谢。
我在curl 的邮件列表上收到了答案。curl CLI工具使用libcurl库。“formdata.c”来自一个库。它已经包含了所有需要的代码。但不幸的是,curl工具没有使用库的这个特定(这是有问题的)功能。这就是为什么上述部分代码根本无法触发(通过 CLI 工具)的原因。
所以我很不幸,但知道这是不可能的,总比根本不知道要好。顺便说一句,我随后尝试修改curl CLI工具源代码,但发现这对我来说远非易事。欢迎任何建议。谢谢
归档时间: |
|
查看次数: |
1414 次 |
最近记录: |