翻譯|使用教程|編輯:董玉霞|2022-03-30 11:00:39.437|閱讀 348 次
概述:本節(jié)介紹 HTTP 請(qǐng)求格式。要在 phpStorm 碼編輯器中編寫(xiě) HTTP 請(qǐng)求,請(qǐng)使用以下通用語(yǔ)法。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷售中 >>
相關(guān)鏈接:
本節(jié)介紹 HTTP 請(qǐng)求格式。要在 phpStorm 碼編輯器中編寫(xiě) HTTP 請(qǐng)求,請(qǐng)使用以下通用語(yǔ)法:
Method Request-URI HTTP-Version Header-field: Header-value Request-Body
// A basic request GET //example.com/a/
// A basic request //example.com/a/
// A basic request //example.com/a/ ###
// A basic request //example.com/a/ ### // A second request using the GET method //example.com:8080/api/html/get?id=123&value=content
// Using line breaks with indent GET //example.com:8080 /api /html /get ?id=123 &value=content
// Basic authentication GET //example.com Authorization: Basic username password ### // Digest authentication GET //example.com Authorization: Digest username password
與其他 HTTP 請(qǐng)求的元素類似,提供的username和password可以通過(guò)環(huán)境變量參數(shù)化。
在請(qǐng)求中,在請(qǐng)求正文前添加一個(gè)空行并執(zhí)行以下操作之一:
// The request body is provided in place POST //example.com:8080/api/html/post HTTP/1.1 Content-Type: application/json Cookie: key=first-value { "key" : "value", "list": [1, 2, 3] }
如果您將Content-Type標(biāo)頭字段值設(shè)置為 PhpStorm 支持的語(yǔ)言之一,則相應(yīng)的語(yǔ)言片段將自動(dòng)注入到 HTTP 請(qǐng)求消息正文中。如果沒(méi)有指定Content-Type ,您可以手動(dòng)注入語(yǔ)言片段。
// The request body is read from a file POST //example.com:8080/api/html/post Content-Type: application/json < ./input.json
POST //example.com/api/upload HTTP/1.1 Content-Type: multipart/form-data; boundary=boundary --boundary Content-Disposition: form-data; name="first"; filename="input.txt" // The 'input.txt' file will be uploaded < ./input.txt --boundary Content-Disposition: form-data; name="second"; filename="input-second.txt" // A temporary 'input-second.txt' file with the 'Text' content will be created and uploaded Text --boundary Content-Disposition: form-data; name="third"; // The 'input.txt' file contents will be sent as plain text. < ./input.txt --boundary--
根據(jù)您訪問(wèn)的 Web 服務(wù),您可能希望 HTTP 請(qǐng)求遵循重定向或不遵循重定向。跟隨重定向時(shí),返回重定向的頁(yè)面響應(yīng);否則,返回實(shí)際的重定向響應(yīng)頭(例如301或302)。
// @no-redirect example.com/status/301
如有必要,您可以阻止將請(qǐng)求保存到requests history。如果請(qǐng)求包含一些敏感數(shù)據(jù)并且您不想記錄它,這會(huì)很有幫助。
// @no-log GET example.com/api
如有必要,您可以阻止將接收到的 cookie 保存到 cookies jar中。這樣,您將避免手動(dòng)從http-client.cookies文件中刪除不需要的 cookie。
// @no-cookie-jar GET example.com/api
以上就是HTTP請(qǐng)求語(yǔ)法的相關(guān)內(nèi)容,下載phpstorm最新版本來(lái)確保自己功能達(dá)到最新。
phpstorm是一個(gè)輕量級(jí)且便捷的PHP IDE,其旨在提高用戶效率,可深刻理解用戶的編碼,提供智能代碼補(bǔ)全,快速導(dǎo)航以及即時(shí)錯(cuò)誤檢查。可隨時(shí)幫助用戶對(duì)其編碼進(jìn)行調(diào)整,運(yùn)行單元測(cè)試或者提供可視化debug功能。
JetBrain技術(shù)交流群現(xiàn)已開(kāi)通,QQ搜索群號(hào)“786598704”,歡迎進(jìn)群討論。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn