我正在嘗試完全像瀏覽器(chrome)一樣模擬HTTP發布文件:HTML:<form name="fnup" method="post" action="action.shtml" enctype="multipart/form-data"> <input name="firmfile" id="firmfile" type="file"> <input type="submit" id="firmbutton" value="Upgrade" class="othsave"></form>C#: public async Task<string> UploadFile(string actionUrl, string filePath) { var httpClient = new HttpClient(); //Should I need to add all those headers??? it will help me? what is necessary? httpClient.DefaultRequestHeaders.Add("Upgrade-Insecure-Requests", "1"); httpClient.DefaultRequestHeaders.Add("Origin", "http://" + ip); httpClient.DefaultRequestHeaders.Add("Upgrade-Insecure-Requests", "1"); httpClient.DefaultRequestHeaders.Add("Pragma", "no-cache");C#示例在我的服務器上不起作用,我不明白為什么...在查看Wireshark之后,我看到了一些不同之處:鉻:C#問題:1)我如何刪除"filename*=utf-8''VP445_all_V116.bin"從Content-Disposition2)為什么我不能看到第二行Content-Type: application/octet-stream像在Chrome?3)內容長度也不相同(甚至是相同的文件)4)底線是C#無法正常工作,chrome正在正常工作,并且服務器端對我來說是黑匣子,所以我需要猜這里我在C#發布請求中做錯了什么。
- 1 回答
- 0 關注
- 288 瀏覽
添加回答
舉報
0/150
提交
取消