Superagent: Support for binary/Buffer posting

Created on 22 Oct 2013  路  2Comments  路  Source: visionmedia/superagent

Hello, I originally posted this in a supertest issue and was asked to repost here.

I am needing to write tests for Adobe AMF requests and responses which are both binary. The mime type is "application/x-amf". I am finding that various sequences of characters are being garbled and I believe this to be because of the utf8 interpretation within JS strings.

I think a great solution would be to allow us to send() a node Buffer class which is made for binary data and perhaps the same in the response.

I notice there is an open issue (Add Buffer support) in here which would solve my problem. There is also some suggested code to add support however, I did a quick patch to try this but it falls over elsewhere so it's not quite as simple as that.

I would be most grateful for any solution which will allow convenient support for sending/receiving binary data...many thanks.

Feature

Most helpful comment

+1.

Not a superagent fix, but here is a workaround I am using in my tests:

var req = http.request({
  hostname: '127.0.0.1',
  port: server.address().port,
  method: 'POST',
  path: '/test'
}, function(res) {
  assert(res.statusCode == 200);
  done();
})
req.write(buffer);
req.end();

All 2 comments

Alright. Follow the other issue #80 for updates.

+1.

Not a superagent fix, but here is a workaround I am using in my tests:

var req = http.request({
  hostname: '127.0.0.1',
  port: server.address().port,
  method: 'POST',
  path: '/test'
}, function(res) {
  assert(res.statusCode == 200);
  done();
})
req.write(buffer);
req.end();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tbo picture tbo  路  4Comments

ropez picture ropez  路  7Comments

pszabop picture pszabop  路  3Comments

littlee picture littlee  路  8Comments

tj picture tj  路  9Comments