Webhooks coming in as application/xml format
jcohenho opened this issue · 4 comments
Issue
The issue mentioned in this older issue seems to have reappeared.
Webhook requests are being sent with an application/xml
format, while the content-type is application/json; charset=utf-8
(ruby@puma: cluster worker 3: 20263 [project]#20280) request.format
#<Mime::Type:0x00000001074a58c8 @hash=-2878860039138727470, @string="application/xml", @symbol=:xml, @synonyms=["text/xml", "application/x-xml"]>
(ruby@puma: cluster worker 3: 20263 [project]#20280) request.content_type
"application/json; charset=utf-8"
Is this to be expected behavior?
Expected Behavior
I expect the request should be sent as a JSON format.
Hey @jcohenho! Could you share the headers you're seeing from the Stripe CLI?
@tomer-stripe Here's an output from the request headers, note the HTTP_ACCEPT value:
(ruby@puma: cluster worker 2: 39111 [side_project]#39127) request.headers.to_h
{"rack.version"=>[1, 6],
"rack.errors"=>#<IO:<STDERR>>,
"rack.multithread"=>true,
"rack.multiprocess"=>false,
"rack.run_once"=>false,
"rack.url_scheme"=>"http",
"SCRIPT_NAME"=>"",
"QUERY_STRING"=>"",
"SERVER_PROTOCOL"=>"HTTP/1.1",
"SERVER_SOFTWARE"=>"puma 5.6.4 Birdie's Version",
"GATEWAY_INTERFACE"=>"CGI/1.2",
"REQUEST_METHOD"=>"POST",
"REQUEST_PATH"=>"/webhooks/stripe",
"REQUEST_URI"=>"/webhooks/stripe",
"HTTP_VERSION"=>"HTTP/1.1",
"HTTP_HOST"=>"localhost:3000",
"HTTP_USER_AGENT"=>"Stripe/1.0 (+https://stripe.com/docs/webhooks)",
"CONTENT_LENGTH"=>"3107",
"HTTP_ACCEPT"=>"*/*; q=0.5, application/xml",
"HTTP_CACHE_CONTROL"=>"no-cache",
"CONTENT_TYPE"=>"application/json; charset=utf-8",
"HTTP_STRIPE_SIGNATURE"=>"redacted",
"HTTP_ACCEPT_ENCODING"=>"gzip",
"puma.request_body_wait"=>0,
"SERVER_NAME"=>"localhost",
"SERVER_PORT"=>"3000",
"PATH_INFO"=>"/webhooks/stripe",
"REMOTE_ADDR"=>"::1",
"puma.socket"=>#<TCPSocket:fd 24, AF_INET6, ::1, 3000>,
"rack.hijack?"=>true,
"rack.hijack"=>#<Puma::Client:0xb220 @ready=true>,
"rack.input"=>#<StringIO:0x000000010a685bu8>,
"rack.after_reply"=>[],
"puma.config"=>
Thank you! Let me poke more. We mostly pass the headers through 1:1 so that's a little odd
stripe-cli/pkg/proxy/endpoint.go
Lines 98 to 110 in df48924
@jcohenho Stripe itself is actually sending webhooks with that accept header. I confirmed that internally and with a test webhook: https://webhook.site/#!/view/6ffabbfa-a78d-4565-94ae-f6eec71f0718/8855e849-c425-4735-a629-bf7c2049e15b/1
I'm not sure if having the CLI change the behavior would be a good idea since this is how the data will be sent to you once you're in production too.