{"library":"smithy-http","title":"Smithy HTTP","type":"library","description":"Smithy-http provides foundational HTTP components and primitives for Smithy tooling in Python. It defines standard interfaces for HTTP requests, responses, headers, and middleware, ensuring compliance with Smithy's protocol specifications. This library is primarily a building block for Smithy-generated Python clients and other Smithy-compliant services. The current version is 0.4.0, and releases are generally tied to the development cadence of the broader `smithy-python` project.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install smithy-http"],"cli":null},"imports":["from smithy_http.request import HttpRequest","from smithy_http.response import HttpResponse","from smithy_http.headers import Headers","from smithy_http.middleware import Middleware"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/smithy-lang/smithy-python","docs":null,"changelog":"https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-http/CHANGELOG.md","pypi":"https://pypi.org/project/smithy-http/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"from smithy_http.request import HttpRequest\nfrom smithy_http.response import HttpResponse\nfrom smithy_http.headers import Headers\nfrom io import BytesIO\n\n# --- Construct an HttpRequest ---\nurl = \"https://example.com/path\"\nmethod = \"POST\"\nheaders = Headers({\"Content-Type\": \"application/json\", \"Accept\": \"application/json\"})\nbody_content = b'{\"key\": \"value\"}'\nbody = BytesIO(body_content)\n\nrequest = HttpRequest(\n    method=method,\n    url=url,\n    headers=headers,\n    body=body\n)\n\nprint(f\"Request Method: {request.method}\")\nprint(f\"Request URL: {request.url}\")\nprint(f\"Request Headers: {dict(request.headers)}\")\nrequest.body.seek(0)\nprint(f\"Request Body: {request.body.read().decode('utf-8')}\")\n\n# --- Construct an HttpResponse ---\nstatus_code = 200\nresponse_headers = Headers({\"Content-Type\": \"application/json\"})\nresponse_body_content = b'{\"message\": \"success\"}'\nresponse_body = BytesIO(response_body_content)\n\nresponse = HttpResponse(\n    status_code=status_code,\n    headers=response_headers,\n    body=response_body\n)\n\nprint(f\"\\nResponse Status Code: {response.status_code}\")\nprint(f\"Response Headers: {dict(response.headers)}\")\nresponse.body.seek(0)\nprint(f\"Response Body: {response.body.read().decode('utf-8')}\")","lang":"python","description":"This quickstart demonstrates how to construct basic `HttpRequest` and `HttpResponse` objects using `smithy-http`'s core components. It highlights how to set the HTTP method, URL, headers, and body for both request and response entities. Note that `smithy-http` does not perform actual network calls; it provides the data structures for them.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}