HttpRequest 類別

HTTP 要求。

它應該傳遞至用戶端的 send_request 方法。


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest('GET', 'http://www.example.com')
<HttpRequest [GET], url: 'http://www.example.com'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
繼承
azure.core.rest._helpers.HttpRequestBackcompatMixin
HttpRequest

建構函式

HttpRequest(method: str, url: str, *, params: Mapping[str, str | int | float | bool | None | Sequence[str | int | float | bool | None]] | None = None, headers: MutableMapping[str, str] | None = None, json: Any = None, content: str | bytes | Iterable[bytes] | AsyncIterable[bytes] | None = None, data: Dict[str, Any] | None = None, files: Mapping[str, str | bytes | IO[str] | IO[bytes] | Tuple[str | None, str | bytes | IO[str] | IO[bytes]] | Tuple[str | None, str | bytes | IO[str] | IO[bytes], str | None]] | Sequence[Tuple[str, str | bytes | IO[str] | IO[bytes] | Tuple[str | None, str | bytes | IO[str] | IO[bytes]] | Tuple[str | None, str | bytes | IO[str] | IO[bytes], str | None]]] | None = None, **kwargs: Any)

參數

method
str
必要

HTTP 方法 (GET、HEAD 等)

url
str
必要

您要求的 URL

params
<xref:mapping>

要對應至 URL 的查詢參數。 您的輸入應該是查詢名稱與查詢值 () 的對應。

headers
<xref:mapping>

您在要求中想要的 HTTP 標頭。 您的輸入應該是標頭名稱與標頭值的對應。

json
any

JSON 可序列化物件。 我們會處理物件的 JSON 序列化,因此請針對比 資料更複雜的資料結構使用此方式。

content
strbytes 或 <xref:iterable>[bytes] 或 <xref:asynciterable>[bytes]

您想要在要求本文中的內容。 如果資料不符合 json資料檔案,請將它視為您應該輸入的 kwarg。 接受位元組類型,或產生位元組的產生器。

data
dict

在要求本文中形成您想要的表單資料。 用於表單編碼的資料,例如 HTML 表單。

files
<xref:mapping>

您想要在要求本文中的檔案。 用於上傳具有多部分編碼的檔案。 您的輸入應該是檔案名與檔案內容的對應。 如果您想要在要求中包含非檔案資料檔案,請使用 資料 kwarg。

變數

url
str

此要求所針對的 URL。

method
str

這個要求的方法型別。

headers
<xref:mapping>

您傳入要求的 HTTP 標頭

content
any

傳入要求的內容

屬性

content

取得要求的內容

傳回

要求的內容

傳回類型

any