Comments (26)
Just stuff the parameters onto the URL:
SELECT status, content
FROM http_delete('http://localhost/openapi/delete?uid=1001');
from pgsql-http.
Thanks for your prompt reply,
Will try this tomorrow.
Regards,
from pgsql-http.
Hi Paul,
No, it doesn't work as expected. Looks like parameters not being sent.
My app will response with the following command
curl -i -X DELETE -H "uid:1001" 'http://localhost/openapi/delete'
from pgsql-http.
Well, that's quite different than a URL parameter, that's a header parameter (-H). While the API provides for custom http_request objects with custom http_headers, unfortunately the code currently ignores custom headers. So, in the Future, you could solve the problem with a custom http_request, but for now you're SOL.
from pgsql-http.
Hi Paul,
Thanks for your explanation. But, I don't want to be SOL.. π
Is there anything I can do to make it happen?
Can I modify your code or add something like this?
CURL_SETOPT(http_handle, CURLOPT_HTTPHEADER, array(content_text));
from pgsql-http.
I just pushed support for optional headers (at c6e0392), give it a try.
SELECT http(
('DELETE',
'http://localhost/openapi/delete/',
ARRAY[('uid','1001')::http_header],
NULL, NULL)::http_request
);
from pgsql-http.
Hi Paul,
Thanks for your help.
I recompiled your patch and this is the result.
psql (9.1.15)
Type "help" for help.
db=# SELECT http(
db(# ('DELETE',
db(# 'http://192.168.0.144/openapi/delete',
db(# ARRAY[('roomnumber','1001')::http_header],
db(# NULL, NULL)::http_request
db(# );
ERROR: invalid memory alloc request size 4057898176
This is the log.
ERROR: invalid memory alloc request size 4057898176
STATEMENT: SELECT http(
('DELETE',
'http://localhost/openapi/delete/',
ARRAY[('uid','1001')::http_header],
NULL, NULL)::http_request
);
from pgsql-http.
Works for me! :) I'll try again here, it's certainly not impossible I've made a memory error somewhere, but I didn't see any issues personally.
from pgsql-http.
Hi Paul,
I just noticed that randomly when query ran, PG server going to recovery
mode and resets all connected clients like network flicker. If The query
excecuted multiple time, PG server went down for a couple of minutes.
Regards,
Senin, 11 Mei 2015, Paul Ramsey [email protected] menulis:
Works for me! :) I'll try again here, it's certainly not impossible I've
made a memory error somewhere, but I didn't see any issues personally.β
Reply to this email directly or view it on GitHub
#14 (comment).
Best Regards,
Yunata Octaviano
from pgsql-http.
Sounds like you're actually crashing your backend. Bad news is: I just downgraded to 9.1 and I'm not seeing the same thing here.
- start postgres and connect
- check your process list and find the pid of the backend you have connected to
- run gdb -p
- hit 'c' in gdb to 'continue' the process
- go to your connection and run the query
- when the crash hits, go back to gdb and run 'bt' to get the 'backtrace'
- paste that here
from pgsql-http.
Paul,
I tried on fresh installed CentOS 6.6 and everything seems in order. I didn't even modify your sql code to get extension installed.
However my production server is on CentOS 5.8.
Will get back to you shortly!
from pgsql-http.
Hi Paul,
I tried to recompile curl libcurl libcurl-devel from 7.15 to 7.21. No error backend anymore.
=# SELECT content FROM http_get('http://www.thomas-bayer.com/sqlrest/INVOICE/');
content
----------------------------------------------------------------------------------------
<?xml version="1.0"?><INVOICEList xmlns:xlink="http://www.w3.org/1999/xlink"> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/0/">0</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/1/">1</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/2/">2</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/3/">3</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/4/">4</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/5/">5</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/6/">6</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/7/">7</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/8/">8</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/9/">9</INVOICE> +
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/10/">10</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/11/">11</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/12/">12</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/13/">13</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/14/">14</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/15/">15</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/16/">16</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/17/">17</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/18/">18</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/19/">19</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/20/">20</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/21/">21</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/22/">22</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/23/">23</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/24/">24</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/25/">25</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/26/">26</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/27/">27</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/28/">28</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/29/">29</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/30/">30</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/31/">31</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/32/">32</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/33/">33</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/34/">34</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/35/">35</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/36/">36</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/37/">37</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/38/">38</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/39/">39</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/40/">40</INVOICE>+
<INVOICE xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/41/">41</INVOICE>+
=# SELECT content FROM http_get('http://www.thomas-bayer.com/sqlrest/INVOICE/41');
content
-----------------------------------------------------------------------------------------------
<?xml version="1.0"?><INVOICE xmlns:xlink="http://www.w3.org/1999/xlink"> +
<ID>41</ID> +
<CUSTOMERID xlink:href="http://www.thomas-bayer.com/sqlrest/CUSTOMER/19/">19</CUSTOMERID>+
<TOTAL>5475.60</TOTAL> +
</INVOICE>
(1 row)
=# SELECT content FROM http_delete('http://www.thomas-bayer.com/sqlrest/INVOICE/41');
content
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?> +
<resource xmlns:xlink="http://www.w3.org/1999/xlink">+
<deleted>41</deleted> +
</resource> +
(1 row)
Will try delete with header parameters tomorrow.
Thank you,
from pgsql-http.
Hm, so maybe need a check on curl version in the headers to can out early with a warning during compilation.
from pgsql-http.
OK, added a version check at 6b7acea
from pgsql-http.
Hi Paul,
DELETE request didn't work.
SELECT http(
('DELETE',
'http://localhost/openapi/delete',
ARRAY[('uid','1001')::http_header],
NULL, NULL)::http_request
);
ERROR query randomly between this
ERROR: number of columns (3368) exceeds limit (1664)
(execution time: 360 ms; total time: 360 ms)
or
ERROR: tupdesc reference 0x369e900 is not owned by resource owner Portal
or
ERROR: invalid memory alloc request size 6737177096
or
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
This debug error when connection reset by peer.
Program received signal SIGQUIT, Quit.
0x00000031f48d4b05 in recv () from /lib64/libc.so.6
(gdb) bt
#0 0x00000031f48d4b05 in recv () from /lib64/libc.so.6
#1 0x0000000000584006 in recv (port=0x35c2670, ptr=0xadbc40, len=8192) at /usr/include/bits/socket2.h:35
#2 secure_read (port=0x35c2670, ptr=0xadbc40, len=8192) at be-secure.c:304
#3 0x000000000058d4b1 in pq_recvbuf () at pqcomm.c:826
#4 0x000000000058d8c7 in pq_getbyte () at pqcomm.c:869
#5 0x000000000062834d in ReadCommand (argc=1, argv=0x7fff3eaa9c10, dbname=0x359d370 "curl", username=0x3643bd0 "") at postgres.c:347
#6 PostgresMain (argc=1, argv=0x7fff3eaa9c10, dbname=0x359d370 "curl", username=0x3643bd0 "") at postgres.c:3978
#7 0x00000000005eb026 in ServerLoop () at postmaster.c:3648
#8 0x00000000005ebf07 in PostmasterMain (argc=5, argv=0x359b950) at postmaster.c:1144
#9 0x000000000058f3d4 in main (argc=5, argv=<value optimized out>) at main.c:210
from pgsql-http.
Platform, version?
from pgsql-http.
Production server
Centos 5.8
Lib curl 7.21
Pgsql 9.1.15
Basically if i could send header with this format "uid:1001" along with custom delete (like method post), it will work.
from pgsql-http.
I don't understand your last sentence. Isn't that what we're working on here?
from pgsql-http.
So The header array will be sent as "uid:1001" on custom delete?
Frustrating.. because, Http_post() is working as is.
from pgsql-http.
Yes, well as 'uid: 1001' (note the space) but yes.
from pgsql-http.
Ok Paul,
Btw you seems made mistake on http--1.1.sql revision. I commented on the code. There were parameters mismatch it should be $1,$3,$2 instead of $1.$2.$3
from pgsql-http.
fix pushed at c35cc26
from pgsql-http.
Just to add
=# SELECT http(('DELETE','http://localhost/openapi/delete', ARRAY[('uid','1001')::http_header], NULL, NULL)::http_request);
Exact Error between this
ERROR: tupdesc reference 0x3694900 is not owned by resource owner Portal
ERROR: number of columns (57160008) exceeds limit (1664)
from pgsql-http.
Sometimes returned with this
(400,application/xml,"{""(Date,\\""Wed, 13 May 2015 02:55:43 GMT\\"")"",""(Server,Apache)"",""(Set-Cookie,ci_session=a%3A5%3A%7Bs%3A10%3A%22user_agent%22%3Bs%3A110%3A%22PostgreSQL+9.1.15+on+x86_64-unknown-linux-gnu%2C+compile)"",""(Status,400)"",""(Content-Length,109)"",""(Connection,close)"",""(Content-Type,application/xml)""}","<?xml version=""1.0"" encoding=""utf-8""?>
<response><status>0</status><error>Unknown method.</error></response>
")
from pgsql-http.
Sorry, I've stood up my own RHEL 5, installed pgsql 9.1 and gotten a recent curl on it, and still cannot duplicate your problem. Not sure what's going on. Feel free to pull the latest version though, there are some fixes in there.
from pgsql-http.
Incredible,
It works but with ERROR: tupdesc reference 0x369ed00 is not owned by resource owner Portal
Thanks Paul
from pgsql-http.
Related Issues (20)
- Undefined symbols for architecture arm64: HOT 1
- Error: invalid cache ID: 78 HOT 1
- send a header along with the post request HOT 1
- PG16 compile error
- build failure "http.c:737:17: warning: βhttp_error_bufferβ may be used uninitialized [-Wmaybe-uninitialized]"
- ERROR: HTTP/2 stream 0 was not closed cleanly: HOT 2
- Violation check constraint "http_method_check" for request 'MKCOL' HOT 7
- Binary File upload HOT 6
- Can't compile against PG16 for latest released 1.5.0 - cut a new release HOT 5
- Handle data with non-standard methods HOT 1
- Deprecation notice CURLOPT_PROTOCOLS is deprecated for curl > 7.85
- Read environment variables for SSL Certificate bundle HOT 2
- Doubts about escape single quote HOT 2
- CURLOPT_DNS_SERVERS "An unknown option was passed in to libcurl" HOT 2
- CURLOPT_SSLCERT_BLOB and CURLOPT_SSLKEY_BLOB
- Include SSL certificate information in the response object HOT 2
- return "content" as bytea HOT 8
- ERROR: HTTP request cancelled HOT 1
- Adding solution to ssl certification issue to README.md
- Setting CURLOPT_TIMEOUT does not have any effect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgsql-http.