Closed htor closed 7 years ago
I'm having troubles getting automatic parse to work with XML responses. Using version ^2.0.1. The JSON responses from the server are parsed successfully into an object, but the XML responses becomes a Buffer for some reason.
^2.0.1
Buffer
client.get('http://localhost:8080/xml', function (data, response) { console.log('GOT DATA:', data); }); --> GOT DATA: <Buffer 3c 78 6d 6c 3e 3c 65 72 72 6f 72 3e 3c 6d 65 73 73 61 67 65 3e 68 65 69 3c 2f 6d 65 73 73 61 67 65 3e 3c 2f 65 72 72 6f 72 3e 3c 2f 78 6d 6c 3e> client.get('http://localhost:8080/js', function (data, response) { console.log('GOT DATA:', data); }); --> GOT DATA: { error: 'error!' }
I have a basic express server set up to test it.
var express = require('express'); var app = express(); app.get('/js', function (req, res) { res.status(500).send({ error: 'error!' }); }); app.get('/xml', function(req, res) { res.set('Content-Type', 'text/xml'); res.status(500).send( '<xml>' + '<error>error!</error>' + '</xml>' ); }); app.listen(8080);
Is this expected behaviour?
Hi no it wasn't the expected behaviour. this bug is fixed in the next version.
thnx.
I just hit this on the current version. Some calls are generating a buffer.
I'm having troubles getting automatic parse to work with XML responses. Using version
^2.0.1
. The JSON responses from the server are parsed successfully into an object, but the XML responses becomes aBuffer
for some reason.I have a basic express server set up to test it.
Is this expected behaviour?