Request

モジュール概要

WSGI request parsing.

チュートリアル

最初に以下の最小例でモジュール利用方法を確認し、その後 API リファレンスを参照してください。

from nexom.app.request import Request

# WSGI app 内で
# req = Request(environ)
# body_json = req.json()
# form = req.form()
# files = req.files()

運用チェックリスト

  • 本番では例外処理を必ず実装し、戻り値の型を固定してください。
  • 引数のデフォルト値と必須/任意を仕様書としてチーム内で固定してください。
  • ログと監視を追加し、エラー時の復旧手順を運用Runbookに記載してください。

API リファレンス(全関数・全メソッド)

クラス

File

分類: public class

Uploaded file container from multipart/form-data.

このクラスにメソッド定義はありません。

Request

分類: public class

Represents an HTTP request constructed from a WSGI environ. Notes: - headers keys are normalized to lower-case - wsgi.input is readable only once; this class caches parsed body per request - .json() / .form() use cached raw body (bytes) - .files() parses multipart/form-data using python-multipart (external dependency) and cannot be used together with .read_body()/.json()/.form() after reading the stream

Request の全メソッド

__init__

分類: special method

シグネチャ
__init__(self, environ: WSGIEnviron, *, max_body_size: int | None = None) -> None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • environ / kind=positional-or-keyword / type=WSGIEnviron / 必須 / default=なし
  • max_body_size / kind=keyword-only / type=int | None / 任意 / default=None
戻り値

None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(environ=..., max_body_size=None)
_parse_cookies

分類: internal method

シグネチャ
_parse_cookies(self) -> RequestCookies | dict[str, str] | None
使い方と仕様

Parse Cookie header into RequestCookies if possible.

引数
  • 引数なし
戻り値

RequestCookies | dict[str, str] | None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(...)
result = obj._parse_cookies()
print(result)
content_type

分類: public method

シグネチャ
content_type(self) -> str
使い方と仕様

Lower-cased mime type without parameters (no charset/boundary). Example: "application/json; charset=utf-8" -> "application/json"

引数
  • 引数なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(...)
result = obj.content_type()
print(result)
_content_length

分類: internal method

シグネチャ
_content_length(self) -> int | None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • 引数なし
戻り値

int | None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(...)
result = obj._content_length()
print(result)
read_body

分類: public method

シグネチャ
read_body(self) -> bytes
使い方と仕様

Read and cache request body bytes. WARNING: - If multipart parsing (.files()) already consumed the stream, body will be empty.

引数
  • 引数なし
戻り値

bytes

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(...)
result = obj.read_body()
print(result)
body

分類: public method

シグネチャ
body(self) -> bytes
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • 引数なし
戻り値

bytes

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(...)
result = obj.body()
print(result)
json

分類: public method

シグネチャ
json(self) -> Any | None
使い方と仕様

Parse application/json body. Returns: Parsed JSON (dict/list/...) or None if not JSON or empty body. Raises: json.JSONDecodeError: If Content-Type is JSON but body is invalid.

引数
  • 引数なし
戻り値

Any | None

例外・注意点
  • json.JSONDecodeError: If Content-Type is JSON but body is invalid.
利用例
from nexom.app.request import Request

obj = Request(...)
result = obj.json()
print(result)
form

分類: public method

シグネチャ
form(self) -> dict[str, list[str]] | None
使い方と仕様

Parse application/x-www-form-urlencoded body. Returns: dict[str, list[str]] or None if not urlencoded form.

引数
  • 引数なし
戻り値

dict[str, list[str]] | None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(...)
result = obj.form()
print(result)
files

分類: public method

シグネチャ
files(self) -> dict[str, str | File] | None
使い方と仕様

Parse multipart/form-data using python-multipart.

引数
  • 引数なし
戻り値

dict[str, str | File] | None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.request import Request

obj = Request(...)
result = obj.files()
print(result)

ソース情報

  • module: nexom.app.request
  • source file: services/venv/lib/python3.10/site-packages/nexom/app/request.py
  • generated date: 2026-03-14