Skip to content

Commit

Permalink
added new field 'headers' to RequestResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
fullerzz committed May 1, 2024
1 parent 89e897c commit 23af30d
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/loamy/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RequestResponse(msgspec.Struct):
request_map: RequestMap
status_code: int
body: dict | None = None
headers: dict[str, str] | None = None
error: BaseException | None = None


Expand Down Expand Up @@ -126,7 +127,11 @@ async def _send_get_request(
logger.trace("Successfully read response as text")
body = {"text": text}
response = RequestResponse(
request_map=req_map, status_code=status_code, body=body, error=error
request_map=req_map,
status_code=status_code,
body=body,
headers=dict(resp.headers),
error=error,
)
return response

Expand All @@ -152,7 +157,11 @@ async def _send_post_request(
logger.trace("Successfully read response as text")
body = {"text": text}
response = RequestResponse(
request_map=req_map, status_code=status_code, body=body, error=error
request_map=req_map,
status_code=status_code,
body=body,
headers=dict(resp.headers),
error=error,
)
return response

Expand All @@ -178,7 +187,11 @@ async def _send_put_request(
logger.trace("Successfully read response as text")
body = {"text": text}
response = RequestResponse(
request_map=req_map, status_code=status_code, body=body, error=error
request_map=req_map,
status_code=status_code,
body=body,
headers=dict(resp.headers),
error=error,
)
return response

Expand All @@ -204,7 +217,11 @@ async def _send_patch_request(
logger.trace("Successfully read response as text")
body = {"text": text}
response = RequestResponse(
request_map=req_map, status_code=status_code, body=body, error=error
request_map=req_map,
status_code=status_code,
body=body,
headers=dict(resp.headers),
error=error,
)
return response

Expand All @@ -230,7 +247,11 @@ async def _send_options_request(
logger.trace("Successfully read response as text")
body = {"text": text}
response = RequestResponse(
request_map=req_map, status_code=status_code, body=body, error=error
request_map=req_map,
status_code=status_code,
body=body,
headers=dict(resp.headers),
error=error,
)
return response

Expand All @@ -256,6 +277,10 @@ async def _send_delete_request(
logger.trace("Successfully read response as text")
body = {"text": text}
response = RequestResponse(
request_map=req_map, status_code=status_code, body=body, error=error
request_map=req_map,
status_code=status_code,
body=body,
headers=dict(resp.headers),
error=error,
)
return response

0 comments on commit 23af30d

Please sign in to comment.