protocol: respect provided mimetype in generated response headers

This commit is contained in:
Robo 2015-09-15 19:54:16 +05:30
parent 6615787775
commit 57c910faef
5 changed files with 57 additions and 1 deletions

View file

@ -318,6 +318,19 @@ describe 'protocol module', ->
error: (xhr, errorType, error) ->
done(error)
it 'can set content-type', (done) ->
handler = (request, callback) ->
callback({mimeType: 'application/json', data: '{"value": 1}'})
protocol.interceptStringProtocol 'http', handler, (error) ->
$.ajax
url: 'http://fake-host'
success: (data) ->
assert.equal typeof(data), 'object'
assert.equal data.value, 1
done()
error: (xhr, errorType, error) ->
done(error)
describe 'protocol.interceptBufferProtocol', ->
it 'can intercept http protocol', (done) ->
handler = (request, callback) -> callback(new Buffer(text))