diff --git a/expected/http.out b/expected/http.out index 53f1a22..b2d09af 100644 --- a/expected/http.out +++ b/expected/http.out @@ -8,7 +8,7 @@ SELECT http_set_curlopt('CURLOPT_TIMEOUT', '10'); -- Status code SELECT status -FROM http_get('http://httpbin.org/status/202'); +FROM http_get('https://httpbin.org/status/202'); status -------- 202 @@ -18,7 +18,7 @@ FROM http_get('http://httpbin.org/status/202'); SELECT * FROM ( SELECT (unnest(headers)).* - FROM http_get('http://httpbin.org/response-headers?Abcde=abcde') + FROM http_get('https://httpbin.org/response-headers?Abcde=abcde') ) a WHERE field = 'Abcde'; field | value @@ -31,12 +31,12 @@ SELECT status, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_get('http://httpbin.org/anything?foo=bar'); - status | args | url | method ---------+------------------+---------------------------------------+-------- - 200 | { +| "http://httpbin.org/anything?foo=bar" | "GET" - | "foo": "bar"+| | - | } | | +FROM http_get('https://httpbin.org/anything?foo=bar'); + status | args | url | method +--------+------------------+----------------------------------------+-------- + 200 | { +| "https://httpbin.org/anything?foo=bar" | "GET" + | "foo": "bar"+| | + | } | | (1 row) -- GET with data @@ -45,10 +45,10 @@ content::json->'args' as args, content::json->>'data' as data, content::json->'url' as url, content::json->'method' as method -from http(('GET', 'http://httpbin.org/anything', NULL, 'application/json', '{"search": "toto"}')); - status | args | data | url | method ---------+------+--------------------+-------------------------------+-------- - 200 | {} | {"search": "toto"} | "http://httpbin.org/anything" | "GET" +from http(('GET', 'https://httpbin.org/anything', NULL, 'application/json', '{"search": "toto"}')); + status | args | data | url | method +--------+------+--------------------+--------------------------------+-------- + 200 | {} | {"search": "toto"} | "https://httpbin.org/anything" | "GET" (1 row) -- DELETE @@ -56,12 +56,12 @@ SELECT status, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_delete('http://httpbin.org/anything?foo=bar'); - status | args | url | method ---------+------------------+---------------------------------------+---------- - 200 | { +| "http://httpbin.org/anything?foo=bar" | "DELETE" - | "foo": "bar"+| | - | } | | +FROM http_delete('https://httpbin.org/anything?foo=bar'); + status | args | url | method +--------+------------------+----------------------------------------+---------- + 200 | { +| "https://httpbin.org/anything?foo=bar" | "DELETE" + | "foo": "bar"+| | + | } | | (1 row) -- PUT @@ -70,12 +70,12 @@ content::json->'data' AS data, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_put('http://httpbin.org/anything?foo=bar','payload','text/plain'); - status | data | args | url | method ---------+-----------+------------------+---------------------------------------+-------- - 200 | "payload" | { +| "http://httpbin.org/anything?foo=bar" | "PUT" - | | "foo": "bar"+| | - | | } | | +FROM http_put('https://httpbin.org/anything?foo=bar','payload','text/plain'); + status | data | args | url | method +--------+-----------+------------------+----------------------------------------+-------- + 200 | "payload" | { +| "https://httpbin.org/anything?foo=bar" | "PUT" + | | "foo": "bar"+| | + | | } | | (1 row) -- PATCH @@ -84,12 +84,12 @@ content::json->'data' AS data, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_patch('http://httpbin.org/anything?foo=bar','{"this":"that"}','application/json'); - status | data | args | url | method ---------+-----------------------+------------------+---------------------------------------+--------- - 200 | "{\"this\":\"that\"}" | { +| "http://httpbin.org/anything?foo=bar" | "PATCH" - | | "foo": "bar"+| | - | | } | | +FROM http_patch('https://httpbin.org/anything?foo=bar','{"this":"that"}','application/json'); + status | data | args | url | method +--------+-----------------------+------------------+----------------------------------------+--------- + 200 | "{\"this\":\"that\"}" | { +| "https://httpbin.org/anything?foo=bar" | "PATCH" + | | "foo": "bar"+| | + | | } | | (1 row) -- POST @@ -98,19 +98,19 @@ content::json->'data' AS data, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_post('http://httpbin.org/anything?foo=bar','payload','text/plain'); - status | data | args | url | method ---------+-----------+------------------+---------------------------------------+-------- - 200 | "payload" | { +| "http://httpbin.org/anything?foo=bar" | "POST" - | | "foo": "bar"+| | - | | } | | +FROM http_post('https://httpbin.org/anything?foo=bar','payload','text/plain'); + status | data | args | url | method +--------+-----------+------------------+----------------------------------------+-------- + 200 | "payload" | { +| "https://httpbin.org/anything?foo=bar" | "POST" + | | "foo": "bar"+| | + | | } | | (1 row) -- HEAD SELECT * FROM ( SELECT (unnest(headers)).* - FROM http_head('http://httpbin.org/response-headers?Abcde=abcde') + FROM http_head('https://httpbin.org/response-headers?Abcde=abcde') ) a WHERE field = 'Abcde'; field | value @@ -122,10 +122,10 @@ WHERE field = 'Abcde'; SELECT status, content::json->'args' AS args, content::json->'url' AS url -FROM http_get('http://httpbin.org/redirect-to?url=http%3A%2F%2Fhttpbin%2Eorg%2Fget%3Ffoo%3Dbar'); - status | args | url ---------+------------------+---------------------------------- - 200 | { +| "http://httpbin.org/get?foo=bar" +FROM http_get('https://httpbin.org/redirect-to?url=http%3A%2F%2Fhttpbin%2Eorg%2Fget%3Ffoo%3Dbar'); + status | args | url +--------+------------------+----------------------------------- + 200 | { +| "https://httpbin.org/get?foo=bar" | "foo": "bar"+| | } | (1 row) @@ -133,7 +133,7 @@ FROM http_get('http://httpbin.org/redirect-to?url=http%3A%2F%2Fhttpbin%2Eorg%2Fg -- Request image WITH http AS ( - SELECT * FROM http_get('http://httpbin.org/image/png') + SELECT * FROM http_get('https://httpbin.org/image/png') ), headers AS ( SELECT (unnest(headers)).* FROM http @@ -157,10 +157,10 @@ SELECT http_set_curlopt('CURLOPT_PROXY', '127.0.0.1'); (1 row) -- Error because proxy is not there -SELECT status FROM http_get('http://httpbin.org/status/555'); +SELECT status FROM http_get('https://httpbin.org/status/555'); ERROR: Failed to connect to 127.0.0.1 port 1080: Connection refused -- Still an error -SELECT status FROM http_get('http://httpbin.org/status/555'); +SELECT status FROM http_get('https://httpbin.org/status/555'); ERROR: Failed to connect to 127.0.0.1 port 1080: Connection refused SELECT http_reset_curlopt(); http_reset_curlopt @@ -169,13 +169,13 @@ SELECT http_reset_curlopt(); (1 row) -- Now it should work -SELECT status FROM http_get('http://httpbin.org/status/555'); +SELECT status FROM http_get('https://httpbin.org/status/555'); status -------- 555 (1 row) --- Alter the default timeout and then run a query that is longer than +-- Alter the default timeout and then run a query that is longer than -- the default (5s), but shorter than the new timeout SELECT http_set_curlopt('CURLOPT_TIMEOUT_MS', '10000'); http_set_curlopt diff --git a/http.c b/http.c index 90109ac..0a93038 100644 --- a/http.c +++ b/http.c @@ -589,9 +589,16 @@ typname_get_tupledesc(const char *extname, const char *typname) foreach(l, fetch_search_path(true)) { Oid typnamespace = lfirst_oid(l); - Oid typoid = GetSysCacheOid2(TYPENAMENSP, + +#if PG_VERSION_NUM >= 120000 + Oid typoid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid, PointerGetDatum(typname), ObjectIdGetDatum(typnamespace)); +#else + Oid typoid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid, + PointerGetDatum(typname), + ObjectIdGetDatum(typnamespace)); +#endif if ( OidIsValid(typoid) ) { diff --git a/sql/http.sql b/sql/http.sql index 577a2b8..246462f 100644 --- a/sql/http.sql +++ b/sql/http.sql @@ -5,13 +5,13 @@ SELECT http_set_curlopt('CURLOPT_TIMEOUT', '10'); -- Status code SELECT status -FROM http_get('http://httpbin.org/status/202'); +FROM http_get('https://httpbin.org/status/202'); -- Headers SELECT * FROM ( SELECT (unnest(headers)).* - FROM http_get('http://httpbin.org/response-headers?Abcde=abcde') + FROM http_get('https://httpbin.org/response-headers?Abcde=abcde') ) a WHERE field = 'Abcde'; @@ -20,7 +20,7 @@ SELECT status, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_get('http://httpbin.org/anything?foo=bar'); +FROM http_get('https://httpbin.org/anything?foo=bar'); -- GET with data SELECT status, @@ -28,14 +28,14 @@ content::json->'args' as args, content::json->>'data' as data, content::json->'url' as url, content::json->'method' as method -from http(('GET', 'http://httpbin.org/anything', NULL, 'application/json', '{"search": "toto"}')); +from http(('GET', 'https://httpbin.org/anything', NULL, 'application/json', '{"search": "toto"}')); -- DELETE SELECT status, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_delete('http://httpbin.org/anything?foo=bar'); +FROM http_delete('https://httpbin.org/anything?foo=bar'); -- PUT SELECT status, @@ -43,7 +43,7 @@ content::json->'data' AS data, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_put('http://httpbin.org/anything?foo=bar','payload','text/plain'); +FROM http_put('https://httpbin.org/anything?foo=bar','payload','text/plain'); -- PATCH SELECT status, @@ -51,7 +51,7 @@ content::json->'data' AS data, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_patch('http://httpbin.org/anything?foo=bar','{"this":"that"}','application/json'); +FROM http_patch('https://httpbin.org/anything?foo=bar','{"this":"that"}','application/json'); -- POST SELECT status, @@ -59,13 +59,13 @@ content::json->'data' AS data, content::json->'args' AS args, content::json->'url' AS url, content::json->'method' AS method -FROM http_post('http://httpbin.org/anything?foo=bar','payload','text/plain'); +FROM http_post('https://httpbin.org/anything?foo=bar','payload','text/plain'); -- HEAD SELECT * FROM ( SELECT (unnest(headers)).* - FROM http_head('http://httpbin.org/response-headers?Abcde=abcde') + FROM http_head('https://httpbin.org/response-headers?Abcde=abcde') ) a WHERE field = 'Abcde'; @@ -73,12 +73,12 @@ WHERE field = 'Abcde'; SELECT status, content::json->'args' AS args, content::json->'url' AS url -FROM http_get('http://httpbin.org/redirect-to?url=http%3A%2F%2Fhttpbin%2Eorg%2Fget%3Ffoo%3Dbar'); +FROM http_get('https://httpbin.org/redirect-to?url=http%3A%2F%2Fhttpbin%2Eorg%2Fget%3Ffoo%3Dbar'); -- Request image WITH http AS ( - SELECT * FROM http_get('http://httpbin.org/image/png') + SELECT * FROM http_get('https://httpbin.org/image/png') ), headers AS ( SELECT (unnest(headers)).* FROM http @@ -93,14 +93,14 @@ WHERE field = 'Content-Length'; -- Alter options and and reset them and throw errors SELECT http_set_curlopt('CURLOPT_PROXY', '127.0.0.1'); -- Error because proxy is not there -SELECT status FROM http_get('http://httpbin.org/status/555'); +SELECT status FROM http_get('https://httpbin.org/status/555'); -- Still an error -SELECT status FROM http_get('http://httpbin.org/status/555'); +SELECT status FROM http_get('https://httpbin.org/status/555'); SELECT http_reset_curlopt(); -- Now it should work -SELECT status FROM http_get('http://httpbin.org/status/555'); +SELECT status FROM http_get('https://httpbin.org/status/555'); --- Alter the default timeout and then run a query that is longer than +-- Alter the default timeout and then run a query that is longer than -- the default (5s), but shorter than the new timeout SELECT http_set_curlopt('CURLOPT_TIMEOUT_MS', '10000'); SELECT status FROM http_get('http://httpstat.us/200?sleep=7000');