Refactor multipart/related logic into separate module #1400
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I just refactored the behavior I proposed here #1283
The
isChunked
,setHeaders
and thebuild
methods can be used outside of this class. Therelated
method just wraps them up, but that logic can be put somewhere else.The reason why I pass the
request
instance to each method individually is because I don't think it belongs to that class as a property. I even allow thesetHeaders
method to modify the instance, so I contradict myself here, I know, but it seemed more logical in this case.Other than that I really want to see a few more modules out of request before I can decide on the best approach about the instance.
I moved the
boundary
field into themultipart
instance, no idea what was the reason to have it attached on therequest
instance, since it wasn't used anywhere else.The
related
method sets up theself._multipart.chunked
and theself._multipart.body
properties, and then use them to pipe with request if needed (not the most elegant code, but that will change I guess)