-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added param response_process (callback) to process response object #10
base: main
Are you sure you want to change the base?
Conversation
@singhsidhukuldeep Please review my pull request, and let me know if something can be improved. Thanks in advance 🙂 |
Please resolve conflicts |
@singhsidhukuldeep Resolved the conflicts - they were because of the commits in main branch since February. |
@singhsidhukuldeep Did you have a chance to review the PR yet? |
I don't think there is any need for this, you can set This will give you the raw response and later you can process it as you want |
@singhsidhukuldeep Setting data = response.read()
encoding = response.info().get_content_charset("utf-8")
decoded_data = data.decode(encoding) # THE BYTES ARE ALWAYS DECODED TO STRING FIRST
self.results[loc] = (
json.loads(
decoded_data) if self.parse_json else decoded_data
)
self.queue.task_done() Decoding the bytes is always done ( |
Makes sense, let's make it parse JSON or parse nothing and return the Request object itself |
That sounds good. But this will break compatibility for existing users - when |
@sohang3112 need to rethink this; people will start adding specific post processes for their own use cases We need to keep it light-weight and extendable one idea is to allow the user to pass their own post-processing logic as a callable function ( |
@singhsidhukuldeep Yes this sounds like a good idea - if a callable is passed, then pass it the request object and use its result. Otherwise do existing processing. |
Sorry closed accidentally 😞 |
@singhsidhukuldeep Should I modify my PR to do this?? |
Yes please
…On Tue, 12 Sept 2023, 4:11 pm Sohang Chopra, ***@***.***> wrote:
if a callable is passed, then pass it the request object and use its
result. Otherwise do existing processing.
@singhsidhukuldeep </~https://github.com/singhsidhukuldeep> Should I modify
my PR to do this??
—
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or unsubscribe
</~https://github.com/notifications/unsubscribe-auth/ACOBEA4PXPSSAGTLFVJWJOLX2A36PANCNFSM6AAAAAAU4Q2YRI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
parse_json
to avoid parsing binary data (eg. image bytes)response_process
(callback) to process response object
response_process
(callback) to process response objectOld param (parse_bytes) was removed as it's no longer used in code
@singhsidhukuldeep I updated the PR to accept optional callback response_ok, data = response_process(response)
|
@singhsidhukuldeep Please review and merge my PR. Let me know if any further changes are needed. |
@singhsidhukuldeep Please merge my PR. Let me know if any further changes are required from my side. |
@singhsidhukuldeep Did you have a chance to review the PR yet? As I mentioned previously, I had modified the PR to include the changes we discussed. |
@singhsidhukuldeep Hi. Did you have a look at the PR yet? As I mentioned before, I modified the PR to include the changes we discussed. |
Hi @sohang3112 |
@singhsidhukuldeep Please review & merge this PR now. |
@singhsidhukuldeep Hi. Please review & merge this PR. |
@singhsidhukuldeep Any update?? Please review & merge this PR. |
Requests to some urls return binary data which cannot be decoded (eg. image data).
In these cases, param
parse_bytes
can be set toFalse
.