Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http headers max length #86

Open
ehjelholt opened this issue Aug 20, 2011 · 1 comment
Open

Http headers max length #86

ehjelholt opened this issue Aug 20, 2011 · 1 comment
Labels

Comments

@ehjelholt
Copy link

When linking to a substantial number of bucket/key pairs and the bucket names and keys are fairly long then the 8k header limit imposed by Apache was hit. This problem has been solved in the Python Riak driver but it keills riak-js.

I made it work by returning an array of link header strings instead of one long string. The http module in Node will turn that array into a series of link headers as prescribed by the http standard and so it should work on any web server. It work in Riak anyway ... but I have not tested it extensively.

Here is the code I used for the linkUtils in http_meta.js

linksToString: function(links, raw) {
var linkHeaders = [];
var max_header_length = 8192 - 6; // substract length of "Link: " header string
var linksLen = links.length;
var linkStr = '', linkStrLen = 0;
while(linksLen--){
var link = links[linksLen];
var curLinkStr = (linkStr == "" ? "" : ", ") + "</" + raw + "/" + (encodeURIComponent(link.bucket)) + "/" + (encodeURIComponent(link.key)) + ">; riaktag="" + (encodeURIComponent(link.tag || "_")) + """;
var curLinkStrLen = curLinkStr.length;
if((linkStrLen + curLinkStrLen) > max_header_length){
linkHeaders.push(linkStr);
linkStr = curLinkStr.substr(2);
continue;
}
linkStr += curLinkStr;
linkStrLen += curLinkStrLen;
}
linkHeaders.push(linkStr);
return linkHeaders.length > 1 ? linkHeaders : linkHeaders[0];
}

@podviaznikov
Copy link
Contributor

+1 for implementing this in the riak-js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants