travis-api/lib/travis/api/app/endpoint
Piotr Sarnacki 260c46181d Add hack to allow handling redirect to logs on the client properly.
This hack is temporary and should be removed when we find better
solution.

TL;DR: we can't handle redirects to S3 using CORS, so in case we want to
get logs from S3 without additional requests to API, we need to return
status that will not be automatically redirected (in this case 204 seems
like the best answer).

Longer rationale:

Old logs are hosted on S3 now and in case log is not available in the
database, we would like to redirect to the archived log. Although S3
support CORS, our use case breaks on some browsers:

  * when request is triggered to /jobs/:id/log and log is archived, api
    returns 302 redirect, Location header points to the log on S3
  * browser transparently redirects to given url, but it sets Origin to
    null, for security reasons
  * "Origin: null" is ok, because we allow every origin by setting
    AllowedOrigin to "*"
  * S3 returns "Access-Control-Allow-Origin: null" header, which breaks
    some browsers (I confirmed it for webkit based browsers)

In order to fix this, S3 would need to return * in
Access-Control-Allow-Origin header or we would need to tell the browser
to not follow redirect. Both solutions are not achiveable.

Another option would be to return log information in job payload - we
could send log_url field which should be either log url on amazon or
null, but in such case we would need to query artifacts table in each
job request. This is something that should be avoided as archived logs
are not frequently requested - slowing down every request to get info
for it would be a waste.
2013-01-29 03:51:22 +01:00
..
documentation vendor bootstrap 2012-08-10 15:55:02 +02:00
accounts.rb use registered services 2012-11-23 21:16:10 +01:00
artifacts.rb comment out put to /artifacts/:id for now 2013-01-26 20:44:04 +01:00
authorization.rb do not require user scope for /auth/github 2013-01-11 17:48:30 +01:00
branches.rb use registered services 2012-11-23 21:16:10 +01:00
broadcasts.rb use registered services 2012-11-23 21:16:10 +01:00
builds.rb Return last builds on each branch for /builds?branches=true 2013-01-26 01:12:47 +01:00
documentation.rb set vary header and cache documentation 2012-09-25 17:52:52 +02:00
endpoints.rb fully implement access tokens 2012-08-15 00:52:22 +02:00
events.rb use registered services 2012-11-23 21:16:10 +01:00
home.rb add config endpoint 2012-09-23 01:43:51 +02:00
hooks.rb use registered services 2012-11-23 21:16:10 +01:00
jobs.rb Add hack to allow handling redirect to logs on the client properly. 2013-01-29 03:51:22 +01:00
repos.rb Add endpoints for key regeneration 2012-12-03 02:54:01 +01:00
requests.rb use travis-core/sf-restart-event 2013-01-17 19:06:34 +01:00
stats.rb use registered services 2012-11-23 21:16:10 +01:00
users.rb add /users/:id 2013-01-21 12:16:51 +01:00
workers.rb pass the api payload type for workers because we now do not return AR scopes any more 2013-01-23 02:44:30 +01:00