No need to do hacks with Location header or Content-Type anymore
This commit is contained in:
parent
5b771aafcc
commit
070d863588
|
@ -51,23 +51,17 @@ Travis.Log.Request = Em.Object.extend
|
||||||
if xhr.status == 204
|
if xhr.status == 204
|
||||||
$.ajax(url: @redirectTo(xhr), type: 'GET', success: @handlers.text)
|
$.ajax(url: @redirectTo(xhr), type: 'GET', success: @handlers.text)
|
||||||
else if @isJson(xhr, body)
|
else if @isJson(xhr, body)
|
||||||
@handlers.json(JSON.parse(body))
|
@handlers.json(body)
|
||||||
else
|
else
|
||||||
@handlers.text(body)
|
@handlers.text(body)
|
||||||
|
|
||||||
redirectTo: (xhr) ->
|
redirectTo: (xhr) ->
|
||||||
# Firefox can't see the Location header on the xhr response due to the wrong
|
# Firefox can't see the Location header on the xhr response due to the wrong
|
||||||
# status code 204. Should be some redirect code but that doesn't work with CORS.
|
# status code 204. Should be some redirect code but that doesn't work with CORS.
|
||||||
xhr.getResponseHeader('Location') || @s3Url()
|
xhr.getResponseHeader('Location')
|
||||||
|
|
||||||
s3Url: ->
|
|
||||||
endpoint = Travis.config.api_endpoint
|
|
||||||
staging = if endpoint.match(/-staging/) then '-staging' else ''
|
|
||||||
host = endpoint.replace(/^https?:\/\//, '').split('.').slice(-2).join('.')
|
|
||||||
"https://s3.amazonaws.com/archive#{staging}.#{host}/jobs/#{@get('id')}/log.txt"
|
|
||||||
|
|
||||||
isJson: (xhr, body) ->
|
isJson: (xhr, body) ->
|
||||||
# Firefox can't see the Content-Type header on the xhr response due to the wrong
|
# Firefox can't see the Content-Type header on the xhr response due to the wrong
|
||||||
# status code 204. Should be some redirect code but that doesn't work with CORS.
|
# status code 204. Should be some redirect code but that doesn't work with CORS.
|
||||||
type = xhr.getResponseHeader('Content-Type') || ''
|
type = xhr.getResponseHeader('Content-Type') || ''
|
||||||
type.indexOf('json') > -1 || body.slice(0, 8) == '{"log":{'
|
type.indexOf('json') > -1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user