Skip to content

Commit e1263d2

Browse files
committed
bodyEncoding: fix was setting 'accept-encoding' header, should be seeing 'accept-charset' header.
1 parent 4a21864 commit e1263d2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = function proxy(host, options) {
8282
reqOpt.headers['content-length'] = getContentLength(bodyContent);
8383

8484
if (bodyEncoding(options)) {
85-
reqOpt.headers[ 'Accept-Encoding' ] = bodyEncoding(options);
85+
reqOpt.headers['Accept-Charset'] = bodyEncoding(options);
8686
}
8787

8888
var realRequest = parsedHost.module.request(reqOpt, function(rsp) {

test/bodyEncoding.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,22 @@ describe('body encoding', function() {
5151
});
5252

5353
});
54+
55+
56+
describe('when user sets reqBodyEncoding', function() {
57+
it('should set the accepts-charset header', function(done) {
58+
var app = express();
59+
app.use(proxy('httpbin.org', {
60+
reqBodyEncoding: 'utf-16'
61+
}));
62+
request(app)
63+
.get('/headers')
64+
.end(function(err, res) {
65+
if (err) { throw err; }
66+
assert.equal(res.body.headers['Accept-Charset'], 'utf-16');
67+
done(err);
68+
});
69+
});
70+
});
5471
});
5572

0 commit comments

Comments
 (0)