-
Notifications
You must be signed in to change notification settings - Fork 16
Optionally enable caching of any request method #24
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
Changes from 1 commit
52b1777
e0c1c0e
0a3b7c8
8151701
baf4fbd
8d9d48c
5b21d4b
cfa6135
8d8f8e9
fbc1dc7
e94b74a
65d819d
10da16c
9703885
490da8b
727cbf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,6 +281,7 @@ private function configureOptions(OptionsResolver $resolver) | |
$resolver->setAllowedTypes('methods', 'array'); | ||
$resolver->setAllowedValues('hash_algo', hash_algos()); | ||
$resolver->setAllowedValues('methods', function ($value) { | ||
/* Any VCHAR, except delimiters. RFC7230 sections 3.1.1 and 3.2.6 */ | ||
$matches = preg_grep('/[^[:alnum:]!#$%&\'*\/+\-.^_`|~]/', $value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks really complicated. Why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I have misunderstood the specs request method can also contain lowercase letters. Valid request methods are described in RFC7230-3.1.1 which states it is a token. Token is defined in RFC7230-3.2.6 which says any visible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, yes you are correct. (Reading the code and RFC more carefully...). I was wrong assuming that HTTP methods are generally uppercase but PSR-7 specifies that case should not change. I think we are correct by running $matches = preg_grep('/[^[A-Z0-9]!#$%&\'*\/+\-.^_`|~]/', $value); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. were do we strtoupper? i think we should leave the method unchanged, given how psr-7 is specified. as mentioned above, guzzle psr-7 request does not follow the SHOULD of the spec. |
||
|
||
return empty($matches); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add a comment here with the RFC number that defines this regular expression? just for future reference and to make it clear we did not come up with a random expression here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am horrible with regular expressions. is this forcing upper case? we should either force that or uppercase ourselves when processing the options. PSR-7 forces method to upper case. when you specify something lower case, it would never match.
the doc should explain that if you specify methods, you also need to specify GET if you still want those cached. and that you should do specific clients with different setup if you do soap and other stuff, to be sure only the right requests get cached...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not force uppercase.
[:alnum:]
is alias for[0-9A-Za-z]
. RFC2616 says method is case-insensitive so technically bothget
andGET
should be valid but just different methods.I have no strong feelings whether we should force uppercase or not. I think most of the time people probably use uppercase methods.
The regexp basically says is request method has any other characters than these the method is invalid.