-
Notifications
You must be signed in to change notification settings - Fork 40
preliminary minimal changes #251
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
base: main
Are you sure you want to change the base?
preliminary minimal changes #251
Conversation
|
Appears to be failing 2 tests for me on MacOS: |
|
Should HTTP::UserAgent be producing valid Messages, or is it up to the users of the library to use it in such a way that it only produces valid messages? Some of the test messages are themselves invalid, so what needs changing will depend on the library's purpose. |
|
Well, that is a good question. What this module really needs, is a maintainer. Would you be willing to take on that role? You apparently have a need to fix things in it :-) |
|
Yes, but I'll need guidance and feedback as I maintain it, if that's okay? Some first questions:
I'll start looking through the other open issues, too. |
|
What would the best channel / medium be for discussing this module? |
|
Either #raku on libera.chat or on Discord |
|
There are enough changes to get things conformant that it would be difficult not to break existing behavior. My plan is to provide alternate classes that can be imported with:
if that is acceptable, though I'm open to other options. |
|
That would make it opt-in, and as such backward compatible. 👍 |
|
I wasn't able to get exporting to work how I was hoping, so instead, the strict versions are just named after the originals with "-Strict" attached. They are subclasses of the originals. The new classes are:
They are all made available with
so that it is easy to just import the strict classes. Behavior when mixing strict and original classes is "undefined". The only change to the original should be the is-chunked multi methods in the HTTP::Message class. One checks the message's own headers, the other takes an arbitrary header object. The following new testcases were added:
I still need to do some testing with the HTTP::UserAgent-Strict class before turning this draft request into a full pull request, but this should be a good place for review and verifying testcases (the new behavior passed for me locally across Windows, Linux, and Mac). |
|
need to fix body-less messages. will comment again once fixed. |
| unit class HTTP::Cookies; | ||
|
|
||
| use HTTP::Cookie; | ||
| use HTTP::Response:auth<zef:raku-community-modules>; |
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 think these were qualified like this because there are un-related packages that provide similarly named modules, so I'd be careful about removing that.
|
My apologies. I am now reading through the META6.json and distributions documentation and committed some fixes. Will the version's patch number eventually need to be updated? |
|
Okay, the META6.json should be fixed. I did not change the version number. |
|
Should this draft be marked ready for review / become a regular pull request? Are there any other changes that would be good before doing so? |
jonathanstowe
left a comment
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.
The only major suggestion I have is really a matter of personal taste: I'm not keen on the -Strict naming. I'm not sure I can completely explain why, but to my eye it would be more regular and consistent if the new classes were named HTTP::UserAgent::Strict, HTTP::Message::Strict and so forth. If nothing else it may make it easier to adapt existing code.
| class HTTP::Header-Strict is HTTP::Header { | ||
| use HTTP::Header::ETag; | ||
|
|
||
| grammar HTTP::Header-Strict::Grammar { |
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.
This could just be named Grammar as it will get a name based on the enclosing package anyway. As it stands if someone wanted to refer to it outside the class they'd have to use HTTP::Header-Strict::HTTP::Header-Strict::Grammar
| self.get-connection($request, $host, $port) | ||
| } | ||
|
|
||
| my $https_lock = Lock.new; |
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'm not sure whether it makes any difference in this case but having this as a my scoped variable in the class body means that every instance in the same process will get the same Lock object. A program might want multiple UA instances with different parameters for some reason.
It could be an attribute that is populated in TWEAK or even with a custom accessor to populate it lazily I suppose.
| multi method get-connection(HTTP::Request-Strict $request, Str $host, Int $port? --> Connection-Strict:D) { | ||
| my $conn; | ||
| if $request.scheme eq 'https' { | ||
| $https_lock.lock; |
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.
Strictly speaking it doesn't matter here (the try require ::("IO::Socket::SSL") can't throw an exception,) but generally :
$https_lock.protect: {
try require ::("IO::Socket::SSL");
};might be preferred: if nothing else it is less typing and another developer doesn't have to scan the code to find the matching unlock.
draft pull request with minimal changes to handle eol. also updates is-chunked check to include the case where multiple Transfer Encodings are present (chunked should always be last).
requesting feedback before final changes.