chilts / awssum-amazon-cloudsearch

(deprecated: use aws-sdk) NodeJS module to talk to Amazon CloudSearch.
Other
5 stars 2 forks source link

Errors when adding documents #2

Closed Jonovono closed 10 years ago

Jonovono commented 11 years ago

I have been using the awssum amazon cloudsearch api for awhile. Just recently I started getting a 411 error when adding a document.

Here is a pastebin: http://pastebin.com/tBrvMWU2

Sometimes I get 411 or 400. It used to work but for some reason just recently stopped and I can't figure out why.

This was the original code I used: https://github.com/Jonovono/node-awssum/blob/master/lib/amazon/cloudsearch.js

Jonovono commented 11 years ago

To fix I had to add: setHeader(options.headers, 'Content-Length', Buffer.byteLength(options.body));

in awssum.js

pboyer commented 11 years ago

RIght, I dropped the following into line 956 of awssum.js. Not sure if this will break other things, though...

    if (options.body){
        options.headers['content-length'] = options.body.length;
    }
chilts commented 11 years ago

Ok cool, thanks. I'll make sure that that gets set in the config.js related to that operation so that it's not in awssum.js (ie. you're right, not everything needs that, but easy enough for me to add to the config).

:)

Cheers, Andy

pboyer commented 11 years ago

Yeah, if it wasn't obvious, it definitely is not safe to put that line in awssum.js. It breaks S3 uploads, for example, that have precomputed Content-Length headers. It also disables chunked encoding.

jhnlsn commented 11 years ago

So what is the fix for this? Are you going to put this into config.js or shoudl I just continue with the hack in awssum.js