pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <bdo id='ooUqG'></bdo><ul id='ooUqG'></ul>

      <i id='ooUqG'><tr id='ooUqG'><dt id='ooUqG'><q id='ooUqG'><span id='ooUqG'><b id='ooUqG'><form id='ooUqG'><ins id='ooUqG'></ins><ul id='ooUqG'></ul><sub id='ooUqG'></sub></form><legend id='ooUqG'></legend><bdo id='ooUqG'><pre id='ooUqG'><center id='ooUqG'></center></pre></bdo></b><th id='ooUqG'></th></span></q></dt></tr></i><div class="mm0xd4v" id='ooUqG'><tfoot id='ooUqG'></tfoot><dl id='ooUqG'><fieldset id='ooUqG'></fieldset></dl></div>

      <small id='ooUqG'></small><noframes id='ooUqG'>

      <tfoot id='ooUqG'></tfoot>

      1. <legend id='ooUqG'><style id='ooUqG'><dir id='ooUqG'><q id='ooUqG'></q></dir></style></legend>
      2. 使用帶有分塊傳輸編碼的 XHR 的 HTTP POST

        HTTP POST using XHR with Chunked Transfer Encoding(使用帶有分塊傳輸編碼的 XHR 的 HTTP POST)
          <bdo id='tGrTh'></bdo><ul id='tGrTh'></ul>
        • <legend id='tGrTh'><style id='tGrTh'><dir id='tGrTh'><q id='tGrTh'></q></dir></style></legend>
          1. <tfoot id='tGrTh'></tfoot>
                  <tbody id='tGrTh'></tbody>

              • <small id='tGrTh'></small><noframes id='tGrTh'>

                  <i id='tGrTh'><tr id='tGrTh'><dt id='tGrTh'><q id='tGrTh'><span id='tGrTh'><b id='tGrTh'><form id='tGrTh'><ins id='tGrTh'></ins><ul id='tGrTh'></ul><sub id='tGrTh'></sub></form><legend id='tGrTh'></legend><bdo id='tGrTh'><pre id='tGrTh'><center id='tGrTh'></center></pre></bdo></b><th id='tGrTh'></th></span></q></dt></tr></i><div class="j333pdr" id='tGrTh'><tfoot id='tGrTh'></tfoot><dl id='tGrTh'><fieldset id='tGrTh'></fieldset></dl></div>
                1. 本文介紹了使用帶有分塊傳輸編碼的 XHR 的 HTTP POST的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個 REST API,它通過 HTTP Post 接受音頻文件.該 API 支持 Transfer-Encoding: 分塊請求標頭,以便文件可以在從客戶端上運行的記錄器創建時分段上傳.這樣,服務器可以在文件到達時開始處理文件以提高性能.例如:

                  <塊引用>

                  HTTP 1.1 POST .../v1/processAudio

                  傳輸編碼:分塊

                  [Chunk 1 256 Bytes](服務器到達時開始處理)

                  [塊 2 256 字節]

                  [塊 3 256 字節]

                  ...

                  音頻文件通常很短,大小約為 10K 到 100K.我有 C# 和 Java 代碼可以工作,所以我知道 API 可以工作.但是,我似乎無法使用 javascript 在瀏覽器中進行錄制和上傳.

                  這是我的測試代碼,它使用傳輸編碼對本地主機進行 POST:

                  <html><腳本類型="文本/javascript">函數流上傳(){var blob = new Blob(['GmnQPBU+nyRGER4JPAW4DjDQC19D']);var xhr = new XMLHttpRequest();//在此處添加任何事件處理程序...xhr.open('POST', '/', true);xhr.setRequestHeader("傳輸編碼", "chunked");xhr.send(blob);}</腳本><身體><div id='demo'>使用 XHR 測試分塊上傳</div><button onclick="streamUpload()">開始上傳</button></身體></html>

                  問題是我在 Chrome 中收到以下錯誤

                  拒絕設置不安全的標頭Transfer-Encoding"

                  streamUpload@uploadTest.html:14onclick@uploadTest.html:24

                  查看 XHR 文檔后,我仍然感到困惑,因為它沒有談論不安全的請求標頭.我想知道 XHR 是否可能不允許或實現 HTTP POST 的 Transfer-Encoding: chunked?

                  我查看了使用多個 XHR.send() 請求和 WebSockets 的變通方案,但兩者都是不可取的,因為它需要對已經到位、簡單、穩定和工作的服務器 API 進行重大更改.唯一的問題是我們似乎無法通過 Transfer-Encoding: chunked request header 從具有偽流的瀏覽器進行 POST.

                  任何想法或建議都會非常有幫助.

                  解決方案

                  正如評論中提到的,您不能設置該標頭,因為它由用戶代理控制.

                  有關完整的標頭集,請參閱 4.6.2 setRequestHeader() 方法 來自 W3C XMLHttpRequest Level 1 并注意 Transfer-Encoding 是由用戶代理控制的標頭之一,以使其控制傳輸的這些方面.

                  • 接受字符集
                  • 接受編碼
                  • 訪問控制請求標頭
                  • 訪問控制請求方法
                  • 連接
                  • 內容長度
                  • Cookie
                  • Cookie2
                  • 日期
                  • DNT
                  • 期待
                  • 主持人
                  • 保持活躍
                  • 原產地
                  • 推薦人
                  • TE
                  • 預告片
                  • 傳輸編碼
                  • 升級
                  • 用戶代理
                  • 通過

                  WhatWG Fetch API 生活標準中有一個類似的列表.https://fetch.spec.whatwg.org/#terminology-headersp>

                  I have a REST API that accepts an Audio file via an HTTP Post. The API has support for Transfer-Encoding: chunked request header so that the file can be uploaded in pieces as it is being created from a recorder running on the client. This way the server can start processing the file as it arrives for improved performance. For example:

                  HTTP 1.1 POST .../v1/processAudio

                  Transfer-Encoding: chunked

                  [Chunk 1 256 Bytes] (server starts processing when arrives)

                  [Chunk 2 256 Bytes]

                  [Chunk 3 256 Bytes]

                  ...

                  The audio files are typically short and are around 10K to 100K in size. I have C# and Java code that is working so I know that API works. However, I cannot seem to get the recording and upload working in a browser using javascript.

                  Here is my Test Code that does a POST to localhost with Transfer-Encoding:

                  <html>
                  <script type="text/javascript">
                    function streamUpload() {
                      var blob = new Blob(['GmnQPBU+nyRGER4JPAW4DjDQC19D']);
                      var xhr = new XMLHttpRequest();
                      // Add any event handlers here...
                      xhr.open('POST', '/', true);
                      xhr.setRequestHeader("Transfer-Encoding", "chunked");
                      xhr.send(blob);
                    }
                  </script>
                  
                  <body>
                    <div id='demo'>Test Chunked Upload using XHR</div>
                    <button onclick="streamUpload()">Start Upload</button>
                  </body>
                  
                  </html>

                  The problem is that i'm receiving the following Error in Chrome

                  Refused to set unsafe header "Transfer-Encoding"

                  streamUpload @ uploadTest.html:14 onclick @ uploadTest.html:24

                  After looking at XHR documentation i'm still confused because it does not talk about unsafe request headers. I'm wondering if its possible that XHR does not allow or implement Transfer-Encoding: chunked for HTTP POST?

                  I've looked at work arounds using multiple XHR.send() requests and WebSockets but both are undesirable because it will require significant changes to the server APIs which are already in place, simple, stable and working. The only issue is that we cannot seem to POST from a browser with psedo-streaming via Transfer-Encoding: chunked request header.

                  Any thoughts or advice would be very helpful.

                  解決方案

                  As was mentioned in a comment, you're not allowed to set that header as it's controlled by the user agent.

                  For the full set of headers, see 4.6.2 The setRequestHeader() method from W3C XMLHttpRequest Level 1 and note that Transfer-Encoding is one of the headers that are controlled by the user agent to let it control those aspects of transport.

                  • Accept-Charset
                  • Accept-Encoding
                  • Access-Control-Request-Headers
                  • Access-Control-Request-Method
                  • Connection
                  • Content-Length
                  • Cookie
                  • Cookie2
                  • Date
                  • DNT
                  • Expect
                  • Host
                  • Keep-Alive
                  • Origin
                  • Referer
                  • TE
                  • Trailer
                  • Transfer-Encoding
                  • Upgrade
                  • User-Agent
                  • Via

                  There is a similar list in the WhatWG Fetch API Living Standard. https://fetch.spec.whatwg.org/#terminology-headers

                  這篇關于使用帶有分塊傳輸編碼的 XHR 的 HTTP POST的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)

                    <bdo id='Vcant'></bdo><ul id='Vcant'></ul>
                    <tfoot id='Vcant'></tfoot>
                        <tbody id='Vcant'></tbody>
                      • <small id='Vcant'></small><noframes id='Vcant'>

                        <legend id='Vcant'><style id='Vcant'><dir id='Vcant'><q id='Vcant'></q></dir></style></legend>

                        1. <i id='Vcant'><tr id='Vcant'><dt id='Vcant'><q id='Vcant'><span id='Vcant'><b id='Vcant'><form id='Vcant'><ins id='Vcant'></ins><ul id='Vcant'></ul><sub id='Vcant'></sub></form><legend id='Vcant'></legend><bdo id='Vcant'><pre id='Vcant'><center id='Vcant'></center></pre></bdo></b><th id='Vcant'></th></span></q></dt></tr></i><div class="dww0i0h" id='Vcant'><tfoot id='Vcant'></tfoot><dl id='Vcant'><fieldset id='Vcant'></fieldset></dl></div>

                          • 主站蜘蛛池模板: 行星齿轮减速机,减速机厂家,山东减速机-淄博兴江机械制造 | 药品仓库用除湿机-变电站用防爆空调-油漆房用防爆空调-杭州特奥环保科技有限公司 | 南京泽朗生物科技有限公司| 浙江浩盛阀门有限公司| IWIS链条代理-ALPS耦合透镜-硅烷预处理剂-上海顶楚电子有限公司 lcd条形屏-液晶长条屏-户外广告屏-条形智能显示屏-深圳市条形智能电子有限公司 | 智能电表|预付费ic卡水电表|nb智能无线远传载波电表-福建百悦信息科技有限公司 | 法兰连接型电磁流量计-蒸汽孔板节流装置流量计-北京凯安达仪器仪表有限公司 | 电缆接头_防水接头_电缆防水接头 - 乐清市新豪电气有限公司 | 高低温万能试验机_拉力试验机_拉伸试验机-馥勒仪器科技(上海)有限公司 | 【德信自动化】点胶机_全自动点胶机_自动点胶机厂家_塑料热压机_自动螺丝机-深圳市德信自动化设备有限公司 | 泉州陶瓷pc砖_园林景观砖厂家_石英砖地铺石价格 _福建暴风石英砖 | 茶叶百科网-茶叶知识与茶文化探讨分享平台 | led太阳能路灯厂家价格_风光互补庭院灯_农村市政工程路灯-中山华可路灯品牌 | SF6环境监测系统-接地环流在线监测装置-瑟恩实业 | 防堵吹扫装置-防堵风压测量装置-电动操作显示器-兴洲仪器 | 环氧乙烷灭菌器_压力蒸汽灭菌器_低温等离子过氧化氢灭菌器 _低温蒸汽甲醛灭菌器_清洗工作站_医用干燥柜_灭菌耗材-环氧乙烷灭菌器_脉动真空压力蒸汽灭菌器_低温等离子灭菌设备_河南省三强医疗器械有限责任公司 | 土壤墒情监测站_土壤墒情监测仪_土壤墒情监测系统_管式土壤墒情站-山东风途物联网 | 山东氧化铁红,山东铁红-淄博科瑞化工有限公司 | 环讯传媒,永康网络公司,永康网站建设,永康小程序开发制作,永康网站制作,武义网页设计,金华地区网站SEO优化推广 - 永康市环讯电子商务有限公司 | 电动不锈钢套筒阀-球面偏置气动钟阀-三通换向阀止回阀-永嘉鸿宇阀门有限公司 | 芜湖厨房设备_芜湖商用厨具_芜湖厨具设备-芜湖鑫环厨具有限公司 控显科技 - 工控一体机、工业显示器、工业平板电脑源头厂家 | 合肥仿石砖_合肥pc砖厂家_合肥PC仿石砖_安徽旭坤建材有限公司 | 展厅设计公司,展厅公司,展厅设计,展厅施工,展厅装修,企业展厅,展馆设计公司-深圳广州展厅设计公司 | 吸音板,隔音板,吸音材料,吸音板价格,声学材料 - 佛山诺声吸音板厂家 | 衬氟止回阀_衬氟闸阀_衬氟三通球阀_衬四氟阀门_衬氟阀门厂-浙江利尔多阀门有限公司 | 招商帮-一站式网络营销服务|互联网整合营销|网络推广代运营|信息流推广|招商帮企业招商好帮手|搜索营销推广|短视视频营销推广 | 薪动-人力资源公司-灵活用工薪资代发-费用结算-残保金优化-北京秒付科技有限公司 | 品牌设计_VI设计_电影海报设计_包装设计_LOGO设计-Bacross新越品牌顾问 | 蜘蛛车-登高车-高空作业平台-高空作业车-曲臂剪叉式升降机租赁-重庆海克斯公司 | 昆明挖掘机修理厂_挖掘机翻新再制造-昆明聚力工程机械维修有限公司 | 乐之康护 - 专业护工服务平台,提供医院陪护-居家照护-居家康复 | 品牌广告服务平台,好排名,好流量,好生意。 | 隔离变压器-伺服变压器--输入输出电抗器-深圳市德而沃电气有限公司 | 卸料器-卸灰阀-卸料阀-瑞安市天蓝环保设备有限公司 | 胶辊硫化罐_胶鞋硫化罐_硫化罐厂家-山东鑫泰鑫智能装备有限公司 意大利Frascold/富士豪压缩机_富士豪半封闭压缩机_富士豪活塞压缩机_富士豪螺杆压缩机 | 聚丙烯酰胺_厂家_价格-河南唐达净水材料有限公司 | 造价工程师网,考试时间查询,报名入口信息-网站首页 | 恒温槽_恒温水槽_恒温水浴槽-上海方瑞仪器有限公司 | YAGEO国巨电容|贴片电阻|电容价格|三星代理商-深圳市巨优电子有限公司 | 浩方智通 - 防关联浏览器 - 跨境电商浏览器 - 云雀浏览器 | 温湿度记录纸_圆盘_横河记录纸|霍尼韦尔记录仪-广州汤米斯机电设备有限公司 |