From 37ea69b55ce7dc60e09f59bb7bbcf41dc3e0a014 Mon Sep 17 00:00:00 2001 From: Steve Chavez Date: Wed, 2 Nov 2022 10:19:42 -0500 Subject: [PATCH] Update pgnet.mdx --- .../docs/guides/database/extensions/pgnet.mdx | 96 ------------------- 1 file changed, 96 deletions(-) diff --git a/apps/reference/docs/guides/database/extensions/pgnet.mdx b/apps/reference/docs/guides/database/extensions/pgnet.mdx index 341af926e44..af190891cd9 100644 --- a/apps/reference/docs/guides/database/extensions/pgnet.mdx +++ b/apps/reference/docs/guides/database/extensions/pgnet.mdx @@ -152,102 +152,6 @@ request_id After triggering `http_post`, use [`http_get_result`](#http_get_result) to get the result of the request. -## `http_collect_response` {#http_collect_response} - -Given a `request_id` reference, retrieves the response. - -When `async:=false` is set it is recommended that [statement_timeout](https://www.postgresql.org/docs/13/runtime-config-client.html) is set for the maximum amount of time the caller is willing to wait in case the response is slow to populate. - -### Signature - -:::caution - -This is a Postgres SECURITY DEFINER function - -::: - -```sql -net.http_collect_response( - -- request_id reference - request_id bigint, - -- when `true`, return immediately. when `false` wait for the request to complete before returning - async bool default true -) - -- http response composite wrapped in a result type - returns net.http_response_result - - strict - volatile - parallel safe -``` - -### Usage - -:::caution - -`net.http_collect_response` must be in a separate transaction from the calls to `net.http_` - -::: - -```sql -select - net.http_post( - url:='https://httpbin.org/post', - body:='{"hello": "world"}'::jsonb - ) as request_id; -request_id ----------- - 1 -(1 row) - -select * from net.http_collect_response(1, async:=false); -status | message | response ---------+---------+---------- -SUCCESS ok ( - status_code := 200, - headers := '{"date": ...}', - body := '{"args": ...}' - )::net.http_response_result - - -select - (response).body::json -from - net.http_collect_response(request_id:=1); - body -------------------------------------------------------------------- - { - "args": {}, - "data": "{\"hello\": \"world\"}", - "files": {}, - "form": {}, - "headers": { - "Accept": "*/*", - "Content-Length": "18", - "Content-Type": "application/json", - "Host": "httpbin.org", - "User-Agent": "pg_net/0.2", - "X-Amzn-Trace-Id": "Root=1-61031a5c-7e1afeae69bffa8614d8e48e" - }, - "json": { - "hello": "world" - }, - "origin": "135.63.38.488", - "url": "https://httpbin.org/post" - } -(1 row) -``` - -Where `response` is a composite: - -```sql -status_code integer -headers jsonb -body text -``` - -Possible values for `net.http_response_result.status` are `('PENDING', 'SUCCESS', 'ERROR')` - ## Resources - Source code: [github.com/supabase/pg_net](https://github.com/supabase/pg_net/)