Skip to content
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

feat: support POST #17

Merged
merged 4 commits into from
Jul 28, 2021
Merged

feat: support POST #17

merged 4 commits into from
Jul 28, 2021

Conversation

soedirgo
Copy link
Member

@soedirgo soedirgo commented Jul 27, 2021

What kind of change does this PR introduce?

Feature

What is the new behavior?

Support POST requests via net.http_post(). Right now the function is mostly copypasting from http_get(), but I think in the future this should be refactored to use a (public?) generic function net.http().

@olirice the order of arguments to net.http_post() is a bit out of place since required arguments have to be listed first - let me know if you want them changed. Also I see I'm failing the pytest stuff - anything I should look at? Do you want me to add a test as well? (haven't looked at how it's setup)

@steve-chavez CMIIW, we currently ignore params and headers in the request right? Atm content_type is handled separately, but I think we should handle it together with headers. In retrospect, I probably should've omitted content_type in the SQL too... (was following pgsql-http) Also, let me know if I've freed the palloc'd stuff properly.

Additional context

Closes #6.

TODOs

@soedirgo soedirgo requested review from steve-chavez and olirice and removed request for steve-chavez July 27, 2021 07:08
@soedirgo soedirgo marked this pull request as ready for review July 27, 2021 07:08
@olirice
Copy link
Collaborator

olirice commented Jul 27, 2021

@soedirgo the background worker crashes while running test suite
Screen Shot 2021-07-27 at 3 52 21 AM

sql/pg_net--0.1.sql Outdated Show resolved Hide resolved
@steve-chavez
Copy link
Member

CMIIW, we currently ignore params and headers in the request right? Atm content_type is handled separately, but I think we should handle it together with headers

@soedirgo Yeah, both ignored. Also agree with the content-type change, Oli has opened an issue for tracking that #23.

@soedirgo soedirgo marked this pull request as ready for review July 27, 2021 18:38
@soedirgo
Copy link
Member Author

soedirgo commented Jul 27, 2021

Both POST and headers should be supported now. As for the remaining issues, they can be handled here or in a separate PR:

  • POST with body null fails despite null checking. Something similar happens when using null body for GET (which is legal HTTP, to my dismay) non-issue, this is because the functions are defined with strict. Is this intended @olirice? Setting e.g. headers to null shouldn't abort the function IMO (though empty jsonb works just as well)
  • memory leak (labeled FIXME), I also suspect we may have other leaks given how many pfrees there are in pgsql-http (even for datum deserializations): https://github.com/pramsey/pgsql-http/blob/1e430f5869234e0c60625eb15a4f7c166cae1abe/http.c#L1006-L1009

@steve-chavez
Copy link
Member

steve-chavez commented Jul 28, 2021

non-issue, this is because the functions are defined with strict

Functions with strict are bad for performance, as noted in this postgrest issue. I think that should be removed.

memory leak (labeled FIXME), I also suspect we may have other leaks given how many pfrees there are in pgsql-http (even for datum deserializations)

Yeah, true. Ideally we'd integrate valgrind and also run it on CI.

src/worker.c Outdated Show resolved Hide resolved
This was referenced Jul 28, 2021
@soedirgo soedirgo merged commit ec78ed5 into master Jul 28, 2021
@soedirgo soedirgo deleted the feat/post branch July 28, 2021 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for http POST
4 participants