cloudendpoints / endpoints-java

A Java framework for building RESTful APIs on Google App Engine
Apache License 2.0
32 stars 35 forks source link

Set CORS-related headers before writing body for flex env support #79

Closed clementdenis closed 7 years ago

clementdenis commented 7 years ago

On flex env, it seems like custom headers set on the response after writing to the body are not always being written to the final http response. This causes CORS support not to work with Cloud Endpints v2 on flex env (it works fine on AppEngine standard though).

Simply changing the code to write CORS headers before the response body fixes the issue. Additionally, it makes any backend error that would happen available to CORS clients as well.

codecov-io commented 7 years ago

Codecov Report

Merging #79 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master     #79   +/-   ##
========================================
  Coverage      79.4%   79.4%           
  Complexity     1618    1618           
========================================
  Files           154     154           
  Lines          5449    5449           
  Branches        702     702           
========================================
  Hits           4327    4327           
  Misses          848     848           
  Partials        274     274
Impacted Files Coverage Δ Complexity Δ
...pi/server/spi/handlers/EndpointsMethodHandler.java 100% <100%> (ø) 10 <0> (ø) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5f73500...6c75b96. Read the comment docs.