-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
5 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ SELECT content::json->'headers'->>'Authorization' | |
(1 row) | ||
``` | ||
|
||
Read the `status` and `content` fields out of a `http_response` object. | ||
Read the `status` and `content_type` fields out of a `http_response` object. | ||
|
||
```sql | ||
SELECT status, content_type | ||
|
@@ -308,21 +308,20 @@ ALTER ROLE myapp IN mydb SET http.curlopt_tlsauth_password = 'secret'; | |
|
||
Using this extension as a background automated process without supervision (e.g as a trigger) may have unintended consequences for other servers. It is considered a best practice to share contact information with your requests, so that administrators can reach you in case your HTTP calls get out of control. | ||
|
||
Certain API policies (e.g. [Wikimedia User-Agent policy](https://meta.wikimedia.org/wiki/User-Agent_policy)) may even require sharing specific contact information | ||
with each request. Others may disallow (via `robots.txt`) certain agents they don't recognize. | ||
Certain API policies (e.g. [Wikimedia User-Agent policy](https://meta.wikimedia.org/wiki/User-Agent_policy)) may even require sharing specific contact information with each request. Others may disallow (via `robots.txt`) certain agents they don't recognize. | ||
|
||
For such cases you can set the `CURLOPT_USERAGENT` option | ||
|
||
```sql | ||
SET http.curlopt_useragent = 'PgBot/2.1 (+http://www.example.com/bot.html) Contact [email protected]'; | ||
SET http.curlopt_useragent = 'PgBot/2.1 (+http://pgbot.com/bot.html) Contact [email protected]'; | ||
|
||
SELECT status, content::json->'headers'->>'User-Agent' | ||
FROM http_get('http://httpbun.com/headers'); | ||
``` | ||
``` | ||
status | user_agent | ||
--------+----------------------------------------------------------- | ||
200 | PgBot/2.1 (+http://www.example.com/bot.html) Contact [email protected] | ||
200 | PgBot/2.1 (+http://pgbot.com/bot.html) Contact [email protected] | ||
``` | ||
|
||
## Keep-Alive & Timeouts | ||
|
@@ -395,5 +394,5 @@ docker run -p 9080:80 kennethreitz/httpbin | |
|
||
## To Do | ||
|
||
- The new http://www.postgresql.org/docs/9.3/static/bgworker.html background worker support could be used to set up an HTTP request queue, so that pgsql-http can register a request and callback and then return immediately. | ||
- The [background worker](https://www.postgresql.org/docs/current/bgworker.html) support could be used to set up an HTTP request queue, so that pgsql-http can register a request and callback and then return immediately. | ||
|