Comments (4)
no, it wasn't implemented.
if you want static configurable header, you can add it in the code:
- parse options, grep for "method_update", it has to be similar.
- setting headers section:
/* in the src/www_fdw.c */
curl_opts = curl_slist_append(curl_opts, "Content-type:");
curl_opts = curl_slist_append(curl_opts, post.content_type.data);
from www_fdw.
Introducing new parameter: request_user_header.
Now you can push own HTTP header.
Clickmeeting need to set X-Api-Key in header.
@@ -64,10 +64,11 @@ static struct WWW_fdw_option valid_options[] =
{ "method_insert", ForeignServerRelationId },
{ "method_delete", ForeignServerRelationId },
{ "method_update", ForeignServerRelationId },
{ "request_user_agent", ForeignServerRelationId },
+ { "request_user_header",ForeignServerRelationId },
{ "request_serialize_callback", ForeignServerRelationId },
{ "request_serialize_type", ForeignServerRelationId },
{ "request_serialize_human_readable", ForeignServerRelationId },
{ "response_type", ForeignServerRelationId },
@@ -95,10 +96,11 @@ typedef struct WWW_fdw_options
char* method_select;
char* method_insert;
char* method_delete;
char* method_update;
char* request_user_agent;
+ char* request_user_header;
char* request_serialize_callback;
char* request_serialize_type;
char* request_serialize_human_readable;
char* response_type;
char* response_deserialize_callback;
@@ -220,10 +222,11 @@ www_fdw_validator(PG_FUNCTION_ARGS)
char *method_select = NULL;
char *method_insert = NULL;
char *method_delete = NULL;
char *method_update = NULL;
char *request_user_agent= NULL;
+ char *request_user_header = NULL;
char *request_serialize_callback = NULL;
char *request_serialize_type = NULL;
char *request_serialize_human_readable = NULL;
char *response_type = NULL;
char *response_deserialize_callback = NULL;
@@ -277,10 +280,11 @@ www_fdw_validator(PG_FUNCTION_ARGS)
if(parse_parameter("method_select", &method_select, def)) continue;
if(parse_parameter("method_insert", &method_insert, def)) continue;
if(parse_parameter("method_delete", &method_delete, def)) continue;
if(parse_parameter("method_update", &method_update, def)) continue;
if(parse_parameter("request_user_agent", &request_user_agent, def)) continue;
+ if(parse_parameter("request_user_header", &request_user_header, def)) continue;
if(parse_parameter("request_serialize_callback", &request_serialize_callback, def)) continue;
if(parse_parameter("request_serialize_type", &request_serialize_type, def)) continue;
if(parse_parameter("request_serialize_human_readable", &request_serialize_human_readable, def))
{
if(
@@ -1396,10 +1400,11 @@ get_www_fdw_options(WWW_fdw_options *opts, Oid *opts_type, Datum *opts_value)
opts->method_insert,
opts->method_delete,
opts->method_update,
opts->request_user_agent,
+ opts->request_user_header,
opts->request_serialize_callback,
opts->request_serialize_type,
opts->request_serialize_human_readable,
opts->response_type,
@@ -1729,10 +1734,11 @@ www_begin(ForeignScanState *node, int eflags)
StringInfoData buffer;
Oid opts_type = 0;
Datum opts_value = 0;
PostParameters post;
struct curl_slist *curl_opts = NULL;
+ int header_set = 0;
d("www_begin routine");
/*
* Do nothing in EXPLAIN
@@ -1777,23 +1783,33 @@ www_begin(ForeignScanState *node, int eflags)
/* interacting with the server */
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url.data);
curl_easy_setopt(curl, CURLOPT_USERAGENT, opts->request_user_agent);
+ if(opts->request_user_header)
+ {
+ curl_opts = curl_slist_append(curl_opts, opts->request_user_header);
+ }
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_error_buffer);
if(post.post || 0 == strcmp(opts->method_select, "POST"))
{
curl_easy_setopt(curl, CURLOPT_POST, 1);
if(0 < post.content_type.len)
{
curl_opts = curl_slist_append(curl_opts, "Content-type:");
curl_opts = curl_slist_append(curl_opts, post.content_type.data);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_opts);
+ header_set = 1;
}
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.data.data);
}
+ if ((opts->request_user_header)&&(0 == header_set))
+ {
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_opts);
+ }
+
/* prepare parsers */
if( 0 == strcmp(opts->response_type, "json") )
{
if(opts->response_deserialize_callback)
{
@@ -2234,10 +2250,13 @@ get_options(Oid foreigntableid, WWW_fdw_options *opts)
opts->method_update = defGetString(def);
if (strcmp(def->defname, "request_user_agent") == 0)
opts->request_user_agent = defGetString(def);
+ if (strcmp(def->defname, "request_user_header") == 0)
+ opts->request_user_header = defGetString(def);
+
if (strcmp(def->defname, "request_serialize_callback") == 0)
opts->request_serialize_callback = defGetString(def);
if (strcmp(def->defname, "request_serialize_type") == 0)
opts->request_serialize_type = defGetString(def);
@@ -2280,10 +2299,11 @@ get_options(Oid foreigntableid, WWW_fdw_options *opts)
if (!opts->method_insert) opts->method_insert = "PUT";
if (!opts->method_delete) opts->method_delete = "DELETE";
if (!opts->method_update) opts->method_update = "POST";
if (!opts->request_user_agent) opts->request_user_agent = "www_fdw postgres extension";
+ if (!opts->request_user_header) opts->request_user_header = "";
if (!opts->request_serialize_type) opts->request_serialize_type = "log";
if (!opts->request_serialize_human_readable) opts->request_serialize_human_readable = "0";
if (!opts->response_type) opts->response_type = "json";
from www_fdw.
@KrzysztofCzajkaTURCOM Any chance you can create a pull request with your changes?
from www_fdw.
@jmealo it's already in the HEAD
from www_fdw.
Related Issues (20)
- Query timeout HOT 1
- Support PostgreSQL 9.5 HOT 1
- Doesn't compile against PostgreSQL 9.5rc1
- Does this support Simple Authentication? HOT 2
- undefined symbol: HeapTupleHeaderGetDatum HOT 1
- ERROR: cannot insert into foreign table "www_fdw_test_search" HOT 1
- Falling PostgreSQL 9.5.3 when calling Google maps API HOT 2
- Doesn't compile against PostgreSQL 9.6 beta3 HOT 3
- Are File Headers Required for CSV? HOT 2
- error while creating Postgres extension www_fdw
- cannot parse json respone when query from foreign table in www_fdw postgresql
- Segmentation Fault HOT 1
- Web API requiring authentication HOT 2
- where in a query
- CSV parser? HOT 1
- SSL SYSCALL error: EOF detected
- New release
- www_fdw crash with postgres 10 HOT 3
- Has anybody succeeded ever to port www_fdw to PG13 or later? HOT 2
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 www_fdw.