You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Franck Eyraud <fr...@nospam.yrnm.net> on 2014/05/17 17:40:42 UTC
Replication through reverse proxy and
Hi List,
I'm trying to use a simple "home made" node.js reverse proxy to do some
access control; I also want the replication to go through this, but it
doesn't go well.
The error from the the log file is this one :
Error in process <0.17319.0> with exit value:
{function_clause,[{string,tokens1,[undefined,";",[]]},{mochiweb_util,parse_header,1},{couch_httpd,get_boundary,1},{couch_httpd,parse_multipart_request,3},{couch_replicator_api_wrap,'-open_doc_revs/6-fun-1-',4},{couch_replicator_httpc...
[info] [<0.16444.0>] Retrying GET to
http://...revs=true&open_revs=%5B%226-650708de185e793a94fab6718fc97e4c%22%5D&latest=true
in 600.0 seconds due to error {function_clause, [{string,
tokens1, [undefined,";",[]]},
{mochiweb_util,parse_header,1},
{couch_httpd,get_boundary,1},
{couch_httpd,parse_multipart_request,3},
{couch_replicator_api_wrap,'-open_doc_revs/6-fun-1-',4},
{couch_replicator_httpc,process_stream_response,5}]}
Some problem in parsing the headers, could it be because the node.js
library transform all the headers in lower case ?
If yes, does someone have some suggestion or other solution to have this
working ?
Or is this just some problem in the proxy ?
Thanks for your help.
Franck
Re: Replication through reverse proxy and
Posted by Franck Eyraud <fr...@nospam.yrnm.net>.
> Some problem in parsing the headers, could it be because the node.js
> library transform all the headers in lower case ?
I'm answering to myself, sorry for bothering, but it might interest some
of you :
Yes, it seems it is the reason : couchdb wants the headers as it emits
them, but node.js for some reason gives them in lower case, we can force
them back to CouchDB format before forwarding to the client :
function uCaseWord(word) {
switch(word) {
case 'etag':return 'ETag';
default: return word.replace(/^./,function(l){return
l.toUpperCase();});
}
}
function uCaseHeader(headerName) {
return headerName.replace(/\w*/g,uCaseWord);
}
function couchDBHeaders(nodeHeaders) {
var couchHeaders={};
for (var i in nodeHeaders) {
couchHeaders[uCaseHeader(i)]=nodeHeaders[i];
}
return couchHeaders;
}
After patching this, I realized that I'm working with node 0.10.28, but
future version of node.js (>= 0.11.6) gives access to the Raw Headers
<https://github.com/joyent/node/pull/5999/commits>
Have a good night,
Franck