-
Notifications
You must be signed in to change notification settings - Fork 22
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
AF-1690 Copy content-type/length on mock-aware fall-through #317
AF-1690 Copy content-type/length on mock-aware fall-through #317
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on HipChat: InfoSec Forum. |
@@ -462,7 +465,7 @@ abstract class CommonRequest extends Object | |||
/// a real request instance (created from a TransportPlatform instance). | |||
/// | |||
/// This is handled by the mock request mixin. | |||
Future<BaseResponse> switchToRealRequest({bool streamResponse}) { |
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 changed this signature so that I could test switchToRealRequest
directly.
if (this is! MultipartRequest) { | ||
realRequest.encoding = encoding; | ||
} | ||
|
||
return streamResponse | ||
? realRequest.streamSend(method) | ||
: realRequest.send(method); |
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 part is just moved to CommonRequest
class above.
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.
Nice
QA +1 this resolves the use case for which I reported the bug! thanks |
@Workiva/release-management-pp |
Problem
When
MockTransports
are installed, requests are wrapped in a "mock-aware" class when constructed. WhenfallThrough: true
, these requests will switch to real requests if there isn't an applicable handler/expectation. This is achieved by constructing a new request instance with the real transport platform on demand and copying all of the request properties over from the mock-aware wrapper to the real request.We weren't copying the
contentType
andcontentLength
properties. If a consumer had explicitly set one of these properties (rare, but does happen), they would not be copied over in this scenario.Solution
Be sure to also copy
contentType
(only if it was explicitly set) andcontentLength
when switching from a mock-aware request to a real request.Testing
Code Review
@Workiva/app-frameworks
@travissanderson-wf