[英]C++ (cpp-netlib) http listener - how to remove headers
我創建了一個 HTTP 監聽器,它接受文件的 POST 請求。 我幾乎完全遵循了這個模板: https://github.com/cpp.netlib/cpp.netlib/blob/main/libs.network/example/http/echo_async_server.cpp
我這樣開始我的監聽器:./build/ ./build/http_listener 0.0.0.0 8000
然后使用 curl 將文件發布到偵聽器: curl --form "fileupload=@file1.txt" -X POST http://127.0.0.1:8000/
我注意到用文件文本填充的變量body__
也用 header 數據填充。 我不想這樣。 如何在沒有任何 header 數據的情況下填充變量body__
?
這是它的樣子:
body__
不會填充 header 數據。 您看到的是您使用--form <name=content>
提交的多部分數據。 如果要提交原始文件數據,請使用另一個 curl 命令:
curl --data-binary "@file1.txt" -H "Content-Type: application/octet-stream" http://127.0.0.1:8000/
如果與--data-binary
、 --data
、 --form
一起使用,則可以省略-X POST
。
不幸的是 curl 沒有發送文件名。 如果服務器端需要文件名,請指定 header Content-Disposition
:
curl --data-binary "@file1.txt" -H "Content-Type: application/octet-stream" -H "Content-Disposition: attachment; filename=file1.txt" http://127.0.0.1:8000/
知識庫
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.