chansen / p5-http-tiny

Tiny HTTP Client
https://metacpan.org/dist/HTTP-Tiny
53 stars 52 forks source link

Is there a way to debug the headers being sent in a request? #144

Closed scottchiefbaker closed 3 years ago

scottchiefbaker commented 3 years ago

I have a REST API doing basic realm authentication that's returning invalid user/pwd. I can run:

curl --silent -k https://user:pass@domain.com/api/v1.0/storage/volume/ 

and get JSON back just fine. Fetching that same URL with HTTP::Tiny gives me an auth error. Is there a way to turn on debugging to show what headers/content was sent as part of the request? I'm flying blind without being able to see what is sent.

karenetheridge commented 3 years ago

There's the poor-man's debugger: sprinkle Data::Dumper (or Data::Printer or Devel::DDCWarn) statements in HTTP::Tiny's code. And then there's the real debugger :)

karenetheridge commented 3 years ago

The key bit, I believe, is dumping $request right after the call to _prepare_headers_and_cb and before write_request.

scottchiefbaker commented 3 years ago

That indeed helped... I printed out the headers and it wasn't sending the auth piece at all. Upgraded my HTTP::Tiny and I'm good to go. Thank you!