-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support reading multipart data with \n
(LF
) lines
#3492
Conversation
e751ef7
to
e9c8c33
Compare
Codecov Report
@@ Coverage Diff @@
## master #3492 +/- ##
==========================================
- Coverage 97.95% 97.93% -0.03%
==========================================
Files 44 44
Lines 8554 8561 +7
Branches 1377 1378 +1
==========================================
+ Hits 8379 8384 +5
- Misses 71 72 +1
- Partials 104 105 +1
Continue to review full report at Codecov.
|
Thanks for the PR! |
Honestly, I'm still not sure, but if it solves user problems and while it's quite cheap (let's not take in account tests...) in implementation it feels fine. So far only @thehesiod reported issue about. We can hold this change for awhile and gather more user feedback to make sure we have strong reasons to relax RFC implemenation on reader part. But it feels for me it will be long time to wait. |
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 does not fix StreamReader.readline
, called via MultipartReader.next
oh, I may have tested this incorrectly, checking |
@thehesiod Hey! (: |
ya I was using the wrong version, sorry, and now and now getting issues starting up multiple threaded servers after conforming to the new APIs. How can I dismiss my review? I'm still trying to get my branch working with these changes, will report back when I have findings. |
IIRC, on merge block right below the comments there should be some button about review cancellation. As backup plan, I can just change the latest commit hash via rebase over master or just ask @asvetlov for |
ok so, after a few tries it works, will have to look into it more later, seems like a multithreading issue with aiohttp (one loop and server per thread with new release), but for now:
thanks guys! sorry about that little disruption, got my virtualenvs confused :) |
btw I don't see anything about cancelling my review there, perhaps asvetlov or you can dismiss my review |
The initial idea is about to autodetect on MultipartReader side, while BodyPartReader have to be informed about what kind of newline to expect. So it should work in seconds case. But since the former one is deep in implementation details, everything should work for you without worry about what kind of newline is there. |
Hm...I should make a test case for this. Hold on. |
sorry not following, from what I understand of this PR, you need to state upfront to your multipart reader what the newline is....which means if I write a server, two things are true:
These are two big negatives. In my case it's ok, because I know upfront what it is, and I don't need to support mixed newline requests. However in general this is not true if you have a generic server, you can't control what format clients will send their newlines. |
No, you don't need to care about what newline is. It handles by this part of changes for you. In other words: first boundary dictates newline format fot the rest ones. |
very cool! 🙇 |
Sorry, I don't follow the design. Looks like Did I miss something? |
@asvetlov |
Is it ready to merge? |
Sorry, not yet. Will be able to finish this a bit later today. |
While RFC clearly says about `CRLF` newlines, there quite a lot of implementations which uses just `LF`. Even Python's stdlib produces multiparts with `\n` newlines by default for compatibility reasons. We wouldn't change how we produce multipart content - here we follow RFC. However, we can detect `\n` lines quite easily which makes their support quite cheap.
e9c8c33
to
d05a640
Compare
@asvetlov |
4308069
to
e66e379
Compare
Just for case. That's a strange case, but it seems we pass it.
This argument is not designed to be defined by users. Depending on parsing multipart newline format it will be chosen automatically and due to recursive native of multipart format it have to be passed around for nested readers.
Thanks! |
Nice work, thank you!! |
🍻 |
@@ -0,0 +1 @@ | |||
Support reading multipart data with `\n` (`LF`) lines |
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.
Hm.. we need to watch for incorrect single quotes in RST...
What do these changes do?
While RFC clearly says about
CRLF
newlines, there quite a lot ofimplementations which uses just
LF
. Even Python's stdlib producesmultiparts with
\n
newlines by default for compatibility reasons.We wouldn't change how we produce multipart content - here we follow
RFC. However, we can detect
\n
lines quite easily which makes theirsupport quite cheap.
Are there changes in behavior for the user?
No notable, except now they can read multipart data with "popular" newlines.
Related issue number
#2302