Draft
Conversation
steve-chavez
commented
Jul 28, 2021
Comment on lines
+387
to
+389
| body_data = (bytea *) palloc(cdata->body->len + VARHDRSZ); | ||
| SET_VARSIZE(body_data, cdata->body->len + VARHDRSZ); | ||
| memcpy(VARDATA(body_data), cdata->body->data, cdata->body->len); |
Member
Author
There was a problem hiding this comment.
This way of converting a char* to bytea is done in many parts of the postgres code(example).
Member
Author
|
We'll hold back merging this one for this release. As @olirice mentioned internally, it's clunky for the client to escape the body since it needs to handle encoding: select
encode((x.response).body, 'escape')::jsonb body_json
from
net.http_collect_response(1, async:=false) x;A new interface like the following needs to be made: select net.http_collect_response_text(request_id:=1)
select net.http_collect_response_bin(request_id:=1)
select net.http_collect_response_json(request_id:=1)But since the most common use case will be getting plain text responses, this can wait. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5.
I've checked the result by downloading an image:
(this way of getting the bytea to a file is mentioned in https://stackoverflow.com/a/6731452/4692662)
With this change, plain text media types have to be encoded. This can be done in pure SQL:
We'd need to accommodate the SQL interface, perhaps it should handle
text/*and someapplication/*media types for knowing when to encode.