You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've captured the HTTP payloads of a request and response on working example (gem v2.1.1) and on a broken example (gem v2.1.2) for you:
v2.1.1 (working as expected)
HTTP Request
PUT /v1/catalog/register HTTP/1.1
User-Agent: Faraday v0.15.4
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Host: localhost:8500
Content-Length: 186
{"Node":"mynode01_consul_registrator","Address":"192.168.34.34","Service":{"Service":"role_base","Address":"192.168.34.34","Port":9100,"Tags":["role_base","consul_registrator"]}}
HTTP Response:
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 19 Mar 2019 21:58:45 GMT
Content-Length: 4
Connection: close
true
v2.1.2 (Not working - Consul returns HTTP 400)
HTTP Request:
PUT /v1/catalog/register HTTP/1.1
User-Agent: Faraday v0.15.4
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Host: localhost:8500
Content-Length: 228
Address=192.168.34.34&Node=mynode01_consul_registrator&Service%5BAddress%5D=192.168.34.34&Service%5BPort%5D=9100&Service%5BService%5D=role_base&Service%5BTags%5D%5B%5D=role_base&Service%5BTags%5D%5B%5D=consul_registrator
HTTP Response:
HTTP/1.1 400 Bad Request
Date: Tue, 19 Mar 2019 21:46:15 GMT
Content-Length: 75
Content-Type: text/plain; charset=utf-8
Connection: close
Request decode failed: invalid character 'A' looking for beginning of value
As you can see above, in both requests Faraday is sending Content-Type: application/x-www-form-urlencoded.
In the first request (v2.1.1) the gem is sending the body as a JSON payload.
In the second request (v2.1.2) the gem is sending the body as a x-www-form-urlencoded payload.
If we make assumptions about what ought to be happening, v2.1.1 is arguably sending the 'incorrect' content-type header with its JSON payload, even though consul successfully accepts the JSON payload with the mismatched header.
However, when we attempt to send it a form-urlencoded payload with an x-www-form-urlencoded content-type header, consul rejects it.
Hi there,
I'm experiencing an issue with version 2.1.2 of this gem that I'm not seeing with v2.1.1.
We're currently using consul v0.7.0 in our environment, and I'm using this gem to make calls to the
/v1/catalog/register
endpoint.I'm making calls similar to this:
I've captured the HTTP payloads of a request and response on working example (gem v2.1.1) and on a broken example (gem v2.1.2) for you:
v2.1.1 (working as expected)
HTTP Request
HTTP Response:
v2.1.2 (Not working - Consul returns HTTP 400)
HTTP Request:
HTTP Response:
As you can see above, in both requests Faraday is sending
Content-Type: application/x-www-form-urlencoded
.In the first request (v2.1.1) the gem is sending the body as a JSON payload.
In the second request (v2.1.2) the gem is sending the body as a x-www-form-urlencoded payload.
If we make assumptions about what ought to be happening, v2.1.1 is arguably sending the 'incorrect' content-type header with its JSON payload, even though consul successfully accepts the JSON payload with the mismatched header.
However, when we attempt to send it a form-urlencoded payload with an x-www-form-urlencoded content-type header, consul rejects it.
I suspect that it's related to the JSON.dump() at https://github.com/WeAreFarmGeek/diplomat/compare/v2.1.1...v2.1.2?diff=split#diff-8f9f0d1ed7f32ce8ac36895fa3a85486R50
Let me know if you require any more information regarding this behaviour, and thanks for your work on this gem!
The text was updated successfully, but these errors were encountered: