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

      <bdo id='v17MI'></bdo><ul id='v17MI'></ul>

    <tfoot id='v17MI'></tfoot>

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

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

      1. <legend id='v17MI'><style id='v17MI'><dir id='v17MI'><q id='v17MI'></q></dir></style></legend>

        HTTP 狀態碼 0 是否有任何意義?

        Does an HTTP Status code of 0 have any meaning?(HTTP 狀態碼 0 是否有任何意義?)
          <tbody id='RjJbH'></tbody>

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

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

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

                <tfoot id='RjJbH'></tfoot>
              1. <legend id='RjJbH'><style id='RjJbH'><dir id='RjJbH'><q id='RjJbH'></q></dir></style></legend>

                • 本文介紹了HTTP 狀態碼 0 是否有任何意義?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  似乎當您從瀏覽器中的腳本發出 XMLHttpRequest 時,如果瀏覽器設置為脫機工作或拔出網線,則請求完成并出現錯誤并且狀態 = 0.0 不是列在允許的 HTTP 狀態代碼中.

                  It appears that when you make an XMLHttpRequest from a script in a browser, if the browser is set to work offline or if the network cable is pulled out, the request completes with an error and with status = 0. 0 is not listed among permissible HTTP status codes.

                  狀態碼 0 是什么意思?對于所有瀏覽器和所有 HTTP 客戶端實用程序,這是否意味著相同的事情?它是 HTTP 規范的一部分還是其他協議規范的一部分?似乎是根本無法發出HTTP請求,可能是因為無法解析服務器地址.

                  What does a status code of 0 mean? Does it mean the same thing across all browsers, and for all HTTP client utilities? Is it part of the HTTP spec or is it part of some other protocol spec? It seems to mean that the HTTP request could not be made at all, perhaps because the server address could not be resolved.

                  什么錯誤信息適合向用戶顯示?要么您沒有連接到互聯網,要么網站遇到問題,或者地址輸入錯誤"?

                  What error message is appropriate to show the user? "Either you are not connected to the internet, or the website is encountering problems, or there might be a typing error in the address"?

                  我應該補充一點,當設置為脫機工作"時,我在 FireFox 中看到了該行為,但在設置為脫機工作"時,在 Microsoft Internet Explorer 中看不到.在 IE 中,用戶會看到一個對話框,提供在線選項.FireFox 在返回錯誤之前不會通知用戶.

                  I should add to this that I see the behavior in FireFox when set to "Work Offline", but not in Microsoft Internet Explorer when set to "Work Offline". In IE, the user gets a dialog giving the option to go online. FireFox does not notify the user before returning the error.

                  我問這個是為了響應顯示更好的錯誤消息"的請求.Internet Explorer 的功能很好.它告訴用戶是什么導致了問題,并為他們提供了修復它的選項.為了提供與 FireFox 等效的 UX,我需要推斷問題的原因并通知用戶.那么我總共可以從狀態 0 中推斷出什么?它有普遍意義還是什么也沒告訴我?

                  I am asking this in response to a request to "show a better error message". What Internet Explorer does is good. It tells the user what is causing the problem and gives them the option to fix it. In order to give an equivalent UX with FireFox I need to infer the cause of the problem and inform the user. So what in total can I infer from Status 0? Does it have a universal meaning or does it tell me nothing?

                  推薦答案

                  簡答

                  這不是 HTTP 響應代碼,但 WhatWG 將其記錄為 XMLHttpRequest 或 Fetch 響應的狀態屬性的有效值.

                  Short Answer

                  It's not a HTTP response code, but it is documented by WhatWG as a valid value for the status attribute of an XMLHttpRequest or a Fetch response.

                  廣義上講,它是在沒有真實 HTTP 狀態代碼要報告和/或發送請求或接收響應時發生錯誤時使用的默認值.出現這種情況的可能場景包括但不限于:

                  Broadly speaking, it is a default value used when there is no real HTTP status code to report and/or an error occurred sending the request or receiving the response. Possible scenarios where this is the case include, but are not limited to:

                  • 請求尚未發送或已中止.
                  • 瀏覽器仍在等待接收響應狀態和標頭.
                  • 請求期間連接斷開.
                  • 請求超時.
                  • 請求遇到無限重定向循環.
                  • 瀏覽器知道響應狀態,但由于與 同源政策.

                  首先,重申一下:0 不是 HTTP 狀態碼.RFC 7231 第 6.1 節 中有完整的列表'不包括 0,第 6 節的介紹清楚地指出

                  First, to reiterate: 0 is not a HTTP status code. There's a complete list of them in RFC 7231 Section 6.1, that doesn't include 0, and the intro to section 6 states clearly that

                  status-code 元素是一個三位整數代碼

                  The status-code element is a three-digit integer code

                  哪個不是 0.

                  然而,記錄了作為 XMLHttpRequest 對象的 .status 屬性的值的 0,盡管跟蹤所有相關細節有點棘手.我們從 https://xhr.spec.whatwg.org/#the-status 開始-attribute,記錄 .status 屬性,簡單說明:

                  However, 0 as a value of the .status attribute of an XMLHttpRequest object is documented, although it's a little tricky to track down all the relevant details. We begin at https://xhr.spec.whatwg.org/#the-status-attribute, documenting the .status attribute, which simply states:

                  status 屬性必須返回 響應狀態.

                  這聽起來可能很空洞且重復,但實際上這里有信息!請記住,本文檔在這里討論的是 XMLHttpRequest.response 屬性,而不是響應,因此這告訴我們 XHR 對象上的狀態定義是延遲的到 Fetch 規范中響應狀態的定義.

                  That may sound vacuous and tautological, but in reality there is information here! Remember that this documentation is talking here about the .response attribute of an XMLHttpRequest, not a response, so this tells us that the definition of the status on an XHR object is deferred to the definition of a response's status in the Fetch spec.

                  但是什么響應對象呢?如果我們實際上還沒有收到回復怎么辦?響應"一詞上的內聯鏈接將我們帶到 https://xhr.spec.whatwg.org/#response,其中解釋:

                  But what response object? What if we haven't actually received a response yet? The inline link on the word "response" takes us to https://xhr.spec.whatwg.org/#response, which explains:

                  XMLHttpRequest 具有關聯的響應.除非另有說明,否則這是一個網絡錯誤.

                  所以我們得到的響應狀態默認是網絡錯誤.通過搜索在 XHR 規范中使用的短語 set response to",我們可以看到它被設置在五個地方:

                  So the response whose status we're getting is by default a network error. And by searching for everywhere the phrase "set response to" is used in the XHR spec, we can see that it's set in five places:

                  • 網絡錯誤,當:

                  • To a network error, when:

                  • open() 方法 被調用,或者
                  • 響應的 body 的 stream 是 errored (請參閱 send() 方法)
                  • 設置了 超時標志,導致 請求錯誤步驟運行
                  • abort() 方法 被調用,導致 請求錯誤步驟 運行
                  • the open() method is called, or
                  • the response's body's stream is errored (see the algorithm described in the docs for the send() method)
                  • the timed out flag is set, causing the request error steps to run
                  • the abort() method is called, causing the request error steps to run

                  對于使用 Fetch 發送請求產生的響應,通過 Fetch 處理響應 任務(如果 XHR 請求是異步的)或 Fetch 處理響應體結束 任務(如果 XHR 請求是同步的).

                  To the response produced by sending the request using Fetch, by way of either the Fetch process response task (if the XHR request is asychronous) or the Fetch process response end-of-body task (if the XHR request is synchronous).

                  查看Fetch 標準,我們可以看到:

                  網絡錯誤是response 其 status 總是 0

                  因此,在 XHR 規范規定響應應設置為網絡錯誤的任何情況下,我們都可以立即知道 XHR 對象的狀態為 0.(有趣的是,這包括正文的流被錯誤"的情況,Fetch 規范告訴我們,在收到狀態之后解析正文時可能會發生這種情況 - 所以理論上我認為這是可能的將 XHR 對象的狀態設置為 200,然后在接收主體時遇到內存不足錯誤或其他問題,因此將其狀態更改回 0.)

                  so we can immediately tell that we'll see a status of 0 on an XHR object in any of the cases where the XHR spec says the response should be set to a network error. (Interestingly, this includes the case where the body's stream gets "errored", which the Fetch spec tells us can happen during parsing the body after having received the status - so in theory I suppose it is possible for an XHR object to have its status set to 200, then encounter an out-of-memory error or something while receiving the body and so change its status back to 0.)

                  我們還注意到在 Fetch 標準中存在一些其他響應類型,它們的狀態定義為 0,它們的存在與跨域請求和同源策略有關:

                  We also note in the Fetch standard that a couple of other response types exist whose status is defined to be 0, whose existence relates to cross-origin requests and the same-origin policy:

                  不透明的過濾響應是 過濾響應,其 ...狀態是 0...

                  An opaque filtered response is a filtered response whose ... status is 0...

                  不透明重定向過濾響應是 過濾響應,其 ... 狀態為 0...

                  An opaque-redirect filtered response is a filtered response whose ... status is 0...

                  (省略了有關這兩種響應類型的其他各種詳細信息).

                  (various other details about these two response types omitted).

                  但除此之外,還有很多情況是 Fetch 算法(而不是我們已經看過的 XHR 規范)要求瀏覽器返回網絡錯誤!實際上,短語return a network error"很重要.在 Fetch 標準中出現 40 次.我不會嘗試在這里列出所有 40 個,但我注意到它們包括:

                  But beyond these, there are also many cases where the Fetch algorithm (rather than the XHR spec, which we've already looked at) calls for the browser to return a network error! Indeed, the phrase "return a network error" appears 40 times in the Fetch standard. I will not try to list all 40 here, but I note that they include:

                  • 請求的方案無法識別的情況(例如,嘗試向 madeupscheme://foobar.com 發送請求)
                  • 非常模糊的指令如有疑問,請返回網絡錯誤."在處理 ftp://和 file://URL 的算法中
                  • 無限重定向:如果請求的重定向計數為 20,則返回網絡錯誤."
                  • 一堆與CORS相關的問題,例如如果httpRequest的響應污染不是cors";并且請求和響應返回阻塞的跨域資源策略檢查,然后返回網絡錯誤."
                  • 連接失敗:如果連接失敗,返回網絡錯誤."
                  • The case where the request's scheme is unrecognised (e.g. trying to send a request to madeupscheme://foobar.com)
                  • The wonderfully vague instruction "When in doubt, return a network error." in the algorithms for handling ftp:// and file:// URLs
                  • Infinite redirects: "If request’s redirect count is twenty, return a network error."
                  • A bunch of CORS-related issues, such as "If httpRequest’s response tainting is not "cors" and the cross-origin resource policy check with request and response returns blocked, then return a network error."
                  • Connection failures: "If connection is failure, return a network error."

                  換句話說:每當出現問題時其他除了從服務器獲取真正的 HTTP 錯誤狀態代碼(如 500 或 400)之外,您最終會在 XHR 對象上獲得狀態屬性 0 或在瀏覽器中獲取響應對象.規范中列舉的可能的具體原因數量眾多.

                  In other words: whenever something goes wrong other than getting a real HTTP error status code like a 500 or 400 from the server, you end up with a status attribute of 0 on your XHR object or Fetch response object in the browser. The number of possible specific causes enumerated in spec is vast.

                  最后:如果您出于某種原因對規范的歷史感興趣,請注意此答案已在 2020 年完全重寫,您可能對 此答案的先前修訂版,在將這些被替換為此答案所指的 WhatWG 規范越現代、越復雜.

                  Finally: if you're interested in the history of the spec for some reason, note that this answer was completely rewritten in 2020, and that you may be interested in the previous revision of this answer, which parsed essentially the same conclusions out of the older (and much simpler) W3 spec for XHR, before these were replaced by the more modern and more complicated WhatWG specs this answers refers to.

                  這篇關于HTTP 狀態碼 0 是否有任何意義?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 部分內容)

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

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

                        <tbody id='EVl4f'></tbody>

                      • <legend id='EVl4f'><style id='EVl4f'><dir id='EVl4f'><q id='EVl4f'></q></dir></style></legend>
                        • <tfoot id='EVl4f'></tfoot>
                            主站蜘蛛池模板: 西安微信朋友圈广告投放_微信朋友圈推广_西安度娘网络科技有限公司 | 金属管浮子流量计_金属转子流量计厂家-淮安润中仪表科技有限公司 | 搪瓷搅拌器,搪玻璃搅拌器,搪玻璃冷凝器_厂家-淄博越宏化工设备 | 招商帮-一站式网络营销服务|搜索营销推广|信息流推广|短视视频营销推广|互联网整合营销|网络推广代运营|招商帮企业招商好帮手 | 协议书_协议合同格式模板范本大全| 精密冲床,高速冲床等冲压设备生产商-常州晋志德压力机厂 | 二手注塑机回收_旧注塑机回收_二手注塑机买卖 - 大鑫二手注塑机 二手光谱仪维修-德国OBLF光谱仪|进口斯派克光谱仪-热电ARL光谱仪-意大利GNR光谱仪-永晖检测 | 对夹式止回阀厂家,温州对夹式止回阀制造商--永嘉县润丰阀门有限公司 | 土壤墒情监测站_土壤墒情监测仪_土壤墒情监测系统_管式土壤墒情站-山东风途物联网 | 上海新光明泵业制造有限公司-电动隔膜泵,气动隔膜泵,卧式|立式离心泵厂家 | 河北凯普威医疗器材有限公司,高档轮椅系列,推车系列,座厕椅系列,协步椅系列,拐扙系列,卫浴系列 | 苏州教学设备-化工教学设备-环境工程教学模型|同科教仪 | 【灵硕展览集团】展台展会设计_展览会展台搭建_展览展示设计一站式服务公司 | 杭州中央空调维修_冷却塔/新风机柜/热水器/锅炉除垢清洗_除垢剂_风机盘管_冷凝器清洗-杭州亿诺能源有限公司 | 除尘器布袋骨架,除尘器滤袋,除尘器骨架,电磁脉冲阀膜片,卸灰阀,螺旋输送机-泊头市天润环保机械设备有限公司 | 上海皓越真空设备有限公司官网-真空炉-真空热压烧结炉-sps放电等离子烧结炉 | 工业硝酸钠,硝酸钠厂家-淄博「文海工贸」| 光泽度计_测量显微镜_苏州压力仪_苏州扭力板手维修-苏州日升精密仪器有限公司 | 超声波分散机-均质机-萃取仪-超声波涂料分散设备-杭州精浩 | 杭州中策电线|中策电缆|中策电线|杭州中策电缆|杭州中策电缆永通集团有限公司 | 德国EA可编程直流电源_电子负载,中国台湾固纬直流电源_交流电源-苏州展文电子科技有限公司 | 2025第九届世界无人机大会| 3d打印服务,3d打印汽车,三维扫描,硅胶复模,手板,快速模具,深圳市精速三维打印科技有限公司 | 手术室净化厂家_成都实验室装修公司_无尘车间施工单位_洁净室工程建设团队-四川华锐16年行业经验 | SMN-1/SMN-A ABB抽屉开关柜触头夹紧力检测仪-SMN-B/SMN-C-上海徐吉 | 诸城网站建设-网络推广-网站优化-阿里巴巴托管-诸城恒泰互联 | 除甲醛公司-甲醛检测-广西雅居环境科技有限公司 | 合肥礼品公司-合肥礼品定制-商务礼品定制公司-安徽柏榽商贸有限公司 | 生态板-实木生态板-生态板厂家-源木原作生态板品牌-深圳市方舟木业有限公司 | 北京包装设计_标志设计公司_包装设计公司-北京思逸品牌设计 | 金属切削液-脱水防锈油-电火花机油-抗磨液压油-深圳市雨辰宏业科技发展有限公司 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 深圳装修_店面装修设计_餐厅设计_装修全包价格-尚泰装饰设计 | 超细|超微气流粉碎机|气流磨|气流分级机|粉体改性机|磨粉机|粉碎设备-山东埃尔派粉体科技 | 废水处理-废气处理-工业废水处理-工业废气处理工程-深圳丰绿环保废气处理公司 | 庭院灯_太阳能景观灯_草坪灯厂家_仿古壁灯-重庆恒投科技 | 欧必特空气能-商用空气能热水工程,空气能热水器,超低温空气源热泵生产厂家-湖南欧必特空气能公司 | 防爆正压柜厂家_防爆配电箱_防爆控制箱_防爆空调_-盛通防爆 | 天津电机维修|水泵维修-天津晟佳机电设备有限公司 | 钢托盘,钢制托盘,立库钢托盘,金属托盘制造商_南京飞天金属制品实业有限公司 | 宽带办理,电信宽带,移动宽带,联通宽带,电信宽带办理,移动宽带办理,联通宽带办理 |