[erlang-questions] avoiding duplicate headers in cowboy

Loïc Hoguin essen@REDACTED
Tue Dec 1 19:43:35 CET 2015


I'll make a guess here: you are passing header names as list to Cowboy? 
The correct type is binary. Dialyzer would probably tell you that.

On 12/01/2015 07:38 PM, Garry Hodgson 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"}
>

-- 
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang



More information about the erlang-questions mailing list