New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cowboy_static + onresponse hook #738

Closed
theonethread opened this Issue Aug 22, 2014 · 5 comments

Comments

Projects
None yet
3 participants
@theonethread

theonethread commented Aug 22, 2014

When the response reaches the 'onresponse' hook serving a static file, the Body parameter is empty (guess it will be later served from disk with some low-cost approach). This way it is not possible, to modify the headers in the response hook, because replying is not possible without the contents of the body, and simply returning the original Request has no effect on the Headers.

For a workaround, I am currently reading the files myself, and sending a response, which I can handle by the hook. Would be nice, if this hook could be used when serving static files (and streams?) too, maybe somehow being able to modify the already computed Headers, when the Body is still not available?

Keep up the great work, cheers!

@essen

This comment has been minimized.

Show comment
Hide comment
@essen

essen Aug 22, 2014

Member

There's an undocumented workaround until a proper fix is in place. Return {Status, Headers, Req}. The onresponse interface will get revamped in Cowboy 2.0 to fix this and a few other issues.

Member

essen commented Aug 22, 2014

There's an undocumented workaround until a proper fix is in place. Return {Status, Headers, Req}. The onresponse interface will get revamped in Cowboy 2.0 to fix this and a few other issues.

@theonethread

This comment has been minimized.

Show comment
Hide comment
@theonethread

theonethread Aug 22, 2014

Thank you for the fast reply, will try it out overnight! :)

theonethread commented Aug 22, 2014

Thank you for the fast reply, will try it out overnight! :)

@essen

This comment has been minimized.

Show comment
Hide comment
@essen

essen Feb 16, 2015

Member

Hope you got it working. As the onresponse interface has another ticket, I'm closing, thanks!

Member

essen commented Feb 16, 2015

Hope you got it working. As the onresponse interface has another ticket, I'm closing, thanks!

@essen essen closed this Feb 16, 2015

@timclassic

This comment has been minimized.

Show comment
Hide comment
@timclassic

timclassic Jun 29, 2015

@essen This workaround worked for me on 2.0.0-pre.1. Is there a different GitHub issue that represents the eventual fix? I searched around but couldn't find one.

timclassic commented Jun 29, 2015

@essen This workaround worked for me on 2.0.0-pre.1. Is there a different GitHub issue that represents the eventual fix? I searched around but couldn't find one.

@essen

This comment has been minimized.

Show comment
Hide comment
@essen

essen Jun 29, 2015

Member

The onresponse interface is removed entirely in Cowboy 2 as it is no longer needed, the low-level Cowboy interface allows you to do the same and much more.

Member

essen commented Jun 29, 2015

The onresponse interface is removed entirely in Cowboy 2 as it is no longer needed, the low-level Cowboy interface allows you to do the same and much more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment