-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change allows caller to observe technical details (e.g. headers, body, etc.) of http requests that are sent in the background of odata calls.
- Loading branch information
Showing
6 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Utilities for Python OData client""" | ||
|
||
from .request_observer import RequestObserver, RequestObserverLastCall | ||
|
||
__all__ = ["RequestObserver", "RequestObserverLastCall"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Interface for request observer, which allows to catch odata request processing details | ||
Author: Michal Nezerka <michal.nezerka@gmail.com> | ||
Date: 2021-05-14 | ||
""" | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
|
||
class RequestObserver(ABC): | ||
""" | ||
The RequestObserver interface declares methods for observing odata request processing. | ||
""" | ||
|
||
@abstractmethod | ||
def http_response(self, response, request) -> None: | ||
""" | ||
Get http response together with related http request object. | ||
""" | ||
|
||
|
||
class RequestObserverLastCall(RequestObserver): | ||
""" | ||
The implementation of RequestObserver that stored request and response of the last call | ||
""" | ||
|
||
def __init__(self): | ||
self.response = None | ||
self.request = None | ||
|
||
def http_response(self, response, request): | ||
self.response = response | ||
self.request = request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters