Skip to content

Commit

Permalink
Added encoding option to request function. Defaults to utf8 as before.
Browse files Browse the repository at this point in the history
Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>
  • Loading branch information
nateps authored and tj committed Apr 25, 2011
1 parent 74f982c commit 1d2c78a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin/expresso
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ assert.response = function(server, req, res, msg){
method = req.method || 'GET',
status = res.status || res.statusCode,
data = req.data || req.body,
requestTimeout = req.timeout || 0;
requestTimeout = req.timeout || 0,
encoding = req.encoding || 'utf8';

var request = client.request(method, req.url, req.headers);

Expand All @@ -427,7 +428,7 @@ assert.response = function(server, req, res, msg){
if (data) request.write(data);
request.on('response', function(response){
response.body = '';
response.setEncoding('utf8');
response.setEncoding(encoding);
response.on('data', function(chunk){ response.body += chunk; });
response.on('end', function(){
if (timer) clearTimeout(timer);
Expand Down
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ <h3 id="assert-response-server-req-res-fn-msg-fn-">assert.response(server, req,
<li><em>method</em> HTTP method</li>
<li><em>data</em> request body</li>
<li><em>headers</em> headers object</li>
<li><em>encoding</em> encoding type</li>
</ul>


Expand Down

0 comments on commit 1d2c78a

Please sign in to comment.