Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library should uppercase HTTP method name #416

Open
ostrolucky opened this issue Aug 9, 2020 · 4 comments
Open

Library should uppercase HTTP method name #416

ostrolucky opened this issue Aug 9, 2020 · 4 comments

Comments

@ostrolucky
Copy link

I was experimenting with using this library as http client for stripe-php, via psr18-adapter/stripe-php that I'm working on now, but had to go back to Guzzle, as Buzz is broken there. You see, stripe library defines lowercased HTTP methods names everywhere, but their servers do not accept those:

❯ curl -XGET "https://api.stripe.com/v1/customers"

{
  "error": {
    "message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.",
    "type": "invalid_request_error"
  }
}
❯ curl -Xget "https://api.stripe.com/v1/customers"
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

I think you might want to make this library uppercase method names as well, like other libraries do. After all, you do that in some places already

@sunkan
Copy link
Contributor

sunkan commented Aug 17, 2020

Hi

The question is where the method normalization belongs.
Should it be in the PSR-18 client or in the PSR-7 request or even in the PSR-17 factory

I think it would probably be best handled inside the client to handle PSR-7 implementations that don't have any validation on the method case.

@ostrolucky
Copy link
Author

I share same opinion. I don't think there currently exist PSR-17 factory or PSR-7 request with this normalization.

@tuupola
Copy link

tuupola commented Dec 11, 2020

HTTP method names are case sensitive. Even though the standardized request methods are by convention uppercase, techically GET, get, gEtand GeT are all valid but also different request methods.

https://tools.ietf.org/html/rfc2616#section-5.1.1
https://tools.ietf.org/html/rfc7231#section-4

IMO libraries should not alter user provided request methods. Instead the user should provide the correct request method. In above case the stripe library should be fixed.

@ostrolucky
Copy link
Author

Why is Buzz doing normalization on some places, but not other places though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants