django處理HTTP請(qǐng)求流程

django處理HTTP請(qǐng)求流程圖
中文版

middleware<--全靠它!

Initializer: init(self)

出于性能的考慮,每個(gè)已啟用的中間件在每個(gè)服務(wù)器進(jìn)程中只初始化一次(服務(wù)進(jìn)程啟動(dòng)的時(shí)候調(diào)用)。

對(duì)自身的檢查

過(guò)。

process_request(self, request)

request預(yù)處理函數(shù)

Django接收到request之后,但仍未解析URL以確定應(yīng)當(dāng)運(yùn)行的view之前。調(diào)用

返回 None(Django將繼續(xù)處理這個(gè)request,執(zhí)行后續(xù)的中間件, 然后調(diào)用相應(yīng)的view,“我對(duì)繼續(xù)處理這個(gè)request沒(méi)意見(jiàn)”)

或者返回 HttpResponse 對(duì)象(Django 將不再執(zhí)行任何其它的中間件(無(wú)視其種類)以及相應(yīng)的view。 Django將立即返回該 HttpResponse,“我不想其他代碼處理這個(gè)request,我要提早返回” ).

process_view(self, request, callback, callback_args, callback_kwargs)

view預(yù)處理函數(shù)

Django執(zhí)行完request預(yù)處理函數(shù)并確定待執(zhí)行的view之后,但在view函數(shù)實(shí)際執(zhí)行之前。

process_response(self, request, response)

Response后處理函數(shù)

在****Django****執(zhí)行view****函數(shù)****并生成****response****之后

該處理器能修改response****的內(nèi)容

django-HttpRequest

HttpRequest.POST

A dictionary-like object containing all given HTTP POST parameters, providing that the request contains form data. See the QueryDict
documentation below. If you need to access raw or non-form data posted in the request, access this through the HttpRequest.body
attribute instead.
It’s possible that a request can come in via POST with an empty POST dictionary – if, say, a form is requested via the POST HTTP method but does not include form data. Therefore, you shouldn’t use ifrequest.POST to check for use of the POST method; instead, use if request.method == "POST" (see above).
Note: POST does not include file-upload information. See FILES
.

類似字典的object,返回所有http post請(qǐng)求的參數(shù),formed data,如果想看原始數(shù)據(jù),HttpRequest.body

可能為空,需要檢測(cè)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容