[erlang-questions] avoiding duplicate headers in cowboy

Geoff Cant nem@REDACTED
Wed Dec 2 22:05:44 CET 2015


Hi there, I’m sure you’re probably well along with your own code, but you may be interested in similar work. Heroku recently released Vegur - https://github.com/heroku/vegur which is the HTTP/1.1 proxy library built on top of cowboy/ranch and used at scale there. Fred and I both haunt this list if you have questions about it. (It may be overkill, but if you need a lot of spec compliance or are doing large scale proxying it is designed for those things)

Cheers,
-Geoff

> On 1 Dec, 2015, at 10:38, Garry Hodgson <garry@REDACTED> wrote:
> 
> I've got an application where I'm using cowboy to build what is,
> in effect, a web proxy. It accepts http/s requests, makes some
> decisions about whether and where to forward, then makes its
> own request of the final endpoint and returns results. it was
> originally written in webmachine and then ported to cowboy.
> 
> everything works fine, but for one small nit. it appears that
> cowboy automagically adds its own headers to the returned
> results, which causes duplicate headers for server, content-type,
> and content-length, as seen below.
> 
> is there some way to avoid this?
> 
> $ curl -X GET http://localhost:8080/v0/log/logs?maxrecords=1 -k -H "$Creds"  -v
> * About to connect() to localhost port 8080 (#0)
> *   Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 8080 (#0)
> > GET /v0/log/logs?maxrecords=1 HTTP/1.1
> > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> > Host: localhost:8080
> > Accept: */*
> > Authorization:  Bearer bc18fb0f-4b1f-493e-823c-fbefa0383e91
> >
> < HTTP/1.1 200 OK
> < connection: keep-alive
> < server: Cowboy
> < date: Tue, 01 Dec 2015 17:34:29 GMT
> < content-length: 71
> < content-type: application/json
> < connection: Keep-Alive
> < date: Tue, 01 Dec 2015 17:34:30 GMT
> < server: AT&T SECWEB 2.1.0
> < content-length: 71
> < content-type: application/json
> < x-powered-by: PHP/5.4.28
> < keep-alive: timeout=5, max=100
> <
> * Connection #0 to host localhost left intact
> * Closing connection #0
> {"error":"Not found","error_description":"Could not read token in CTS"}
> 
> -- 
> Garry Hodgson
> Lead Member of Technical Staff
> AT&T Chief Security Office (CSO)
> 
> "This e-mail and any files transmitted with it are AT&T property, are confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not one of the named recipient(s) or otherwise have reason to believe that you have received this message in error, please notify the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited."
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list