<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ### POST_READ階段[](http://tengine.taobao.org/book/chapter_12.html#post-read "永久鏈接至標題") POST_READ階段是nginx處理請求流程中第一個可以添加模塊函數的階段,任何需要在接收完請求頭之后立刻處理的邏輯可以在該階段注冊處理函數。nginx源碼中只有realip模塊在該階段注冊了函數,當nginx前端多了一個7層負載均衡層,并且客戶端的真實ip被前端保存在請求頭中時,該模塊用來將客戶端的ip替換為請求頭中保存的值。realip模塊之所以在POST_READ階段執行的原因是它需要在其他模塊執行之前悄悄的將客戶端ip替換為真實值,而且它需要的信息僅僅只是請求頭。一般很少有模塊需要注冊在POST_READ階段,realip模塊默認沒有編譯進nginx。 POST_READ階段的checker函數是ngx_http_core_generic_phase,這個函數是nginx phase默認的checker函數,后面的PREACCESS phase也是用checker,下面對它做一下介紹: [](http:// "點擊提交Issue,反饋你的意見...") ngx_int_t ngx_http_core_generic_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph) { ngx_int_t rc; /* * generic phase checker, * used by the post read and pre-access phases */ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "generic phase: %ui", r->phase_handler); rc = ph->handler(r); if (rc == NGX_OK) { r->phase_handler = ph->next; return NGX_AGAIN; } if (rc == NGX_DECLINED) { r->phase_handler++; return NGX_AGAIN; } if (rc == NGX_AGAIN || rc == NGX_DONE) { return NGX_OK; } /* rc == NGX_ERROR || rc == NGX_HTTP_... */ ngx_http_finalize_request(r, rc); return NGX_OK; } 這個函數邏輯非常簡單,調用該phase注冊的handler函數,需要注意的是該函數對handler返回值的處理,一般而言handler返回: <table class="docutils field-list" frame="void" rules="none" style="margin: 0px -0.5em; border: 0px; color: rgb(0, 0, 0); font-family: 'segoe UI', sans-serif; letter-spacing: -0.1599999964237213px; line-height: 24px; white-space: normal; background-color: rgb(255, 255, 255);"><colgroup><col class="field-name"/><col class="field-body"/></colgroup><tbody valign="top"><tr class="field-odd field"><th class="field-name" style="padding: 1px 8px 1px 5px; border: 0px !important;">NGX_OK:</th><td class="field-body" style="padding: 1px 8px 1px 5px; border: 0px !important;">表示該階段已經處理完成,需要轉入下一個階段;</td></tr><tr class="field-even field"><th class="field-name" style="padding: 1px 8px 1px 5px; border: 0px !important;">NG_DECLINED:</th><td class="field-body" style="padding: 1px 8px 1px 5px; border: 0px !important;">表示需要轉入本階段的下一個handler繼續處理;</td></tr><tr class="field-odd field"><th class="field-name" colspan="2" style="padding: 1px 8px 1px 5px; border: 0px !important;">NGX_AGAIN, NGX_DONE:</th></tr><tr class="field-odd field"><td style="padding: 1px 8px 1px 5px; border: 0px !important;">?</td><td class="field-body" style="padding: 1px 8px 1px 5px; border: 0px !important;">表示需要等待某個事件發生才能繼續處理(比如等待網絡IO),此時Nginx為了不阻塞其他請求的處理,必須中斷當前請求的執行鏈,等待事件發生之后繼續執行該handler;</td></tr><tr class="field-even field"><th class="field-name" style="padding: 1px 8px 1px 5px; border: 0px !important;">NGX_ERROR:</th><td class="field-body" style="padding: 1px 8px 1px 5px; border: 0px !important;">表示發生了錯誤,需要結束該請求。</td></tr></tbody></table> checker函數根據handler函數的不同返回值,給上一層的ngx_http_core_run_phases函數返回NGX_AGAIN或者NGX_OK,如果期望上一層繼續執行后面的phase則需要確保checker函數不是返回NGX_OK,不同checker函數對handler函數的返回值處理還不太一樣,開發模塊時需要確保相應階段的checker函數對返回值的處理在你的預期之內。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看