-
Notifications
You must be signed in to change notification settings - Fork 12
Bugfix/upstream stream io fix #11
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
Bugfix/upstream stream io fix #11
Conversation
commit ba304a1 Author: Frank Cobia <frank_cobia@me.com> Date: Sat Aug 15 14:15:33 2020 -0400 Ran swift format commit 443f625 Author: Frank Cobia <frank_cobia@me.com> Date: Sat Aug 15 14:05:53 2020 -0400 Make the cookies code more compact commit 58f1d7b Author: Frank Cobia <frank_cobia@me.com> Date: Sat Aug 15 13:46:34 2020 -0400 Testing without the call to buffer commit 14f6786 Author: Frank Cobia <frank_cobia@me.com> Date: Thu Aug 13 21:21:36 2020 -0400 Removed debugging code commit 5b6841b Author: Frank Cobia <frank_cobia@me.com> Date: Wed Aug 12 22:15:31 2020 -0400 Attempting to work with streams commit e339fc9 Author: Frank Cobia <frank_cobia@me.com> Date: Wed Aug 12 02:02:37 2020 -0400 Removed the streaming code for the response commit 75a605b Author: Frank Cobia <frank_cobia@me.com> Date: Wed Aug 12 00:54:49 2020 -0400 Fixed a compiler error commit 334b559 Author: Frank Cobia <frank_cobia@me.com> Date: Wed Aug 12 00:50:51 2020 -0400 Collect stream body commit e836aed Author: Frank Cobia <frank_cobia@me.com> Date: Wed Aug 12 00:06:12 2020 -0400 Check the response body for bytes commit 4b3de95 Author: Frank Cobia <frank_cobia@me.com> Date: Tue Aug 11 23:45:31 2020 -0400 More debugging code commit 3fff709 Author: Frank Cobia <frank_cobia@me.com> Date: Tue Aug 11 23:32:17 2020 -0400 Added some debugging code commit 491867f Merge: 4aa8155 9bb4790 Author: Frank Cobia <frank_cobia@me.com> Date: Tue Aug 11 22:20:35 2020 -0400 Merge branch 'bugfix/PRChanges' into debugging commit 9bb4790 Author: Frank Cobia <frank_cobia@me.com> Date: Tue Aug 11 22:20:15 2020 -0400 Ran swiftformat commit 7089d2f Author: Frank Cobia <frank_cobia@me.com> Date: Tue Aug 11 22:11:28 2020 -0400 Undo the cookie change commit 4aa8155 Author: Frank Cobia <frank_cobia@me.com> Date: Tue Aug 11 19:24:41 2020 -0400 Ran swiftformat commit 78f6e19 Author: fcobia <frank_cobia@me.com> Date: Tue Aug 11 19:20:36 2020 -0400 Update Sources/VaporAWSLambdaRuntime/APIGatewayV2.swift Co-authored-by: Fabian Fett <fabianfett@mac.com> commit d2172d2 Author: Frank Cobia <frank_cobia@me.com> Date: Sat Aug 8 11:34:21 2020 -0400 Attempting to fix query parameters commit d7e2b9b Author: Frank Cobia <frank_cobia@me.com> Date: Sun Jul 26 11:47:06 2020 -0400 Attempting to fix the cookies
Codecov Report
@@ Coverage Diff @@
## main #11 +/- ##
========================================
- Coverage 0.02% 0.02% -0.01%
========================================
Files 509 531 +22
Lines 36361 39630 +3269
========================================
Hits 8 8
- Misses 36353 39622 +3269
Continue to review full report at Codecov.
|
@fcobia Oh my god! I'm so sorry for not having reviewed this yet. I thought I had but apparently, I didn't. So Sorry. |
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.
@fcobia Thanks so much. This looks really good, I do have a few comments...
And once again, I'm so sorry for not looking at this earlier.
var headers = [String: [String]]() | ||
static func from(response: Vapor.Response, in context: Lambda.Context) -> EventLoopFuture<APIGateway.V2.Response> { | ||
// Create the promise | ||
let promise = context.eventLoop.makePromise(of: APIGateway.V2.Response.self) |
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, we don't need to create a Promise here.
Co-authored-by: Fabian Fett <fabianfett@mac.com>
Co-authored-by: Fabian Fett <fabianfett@mac.com>
Co-authored-by: Fabian Fett <fabianfett@mac.com>
I am new to Swift NIO and Vapor, so I am just trying to find my way through it. I took your changes and I re-ran my website in AWS and it works. |
@fcobia awesome. Do you want to run |
Done |
This PR would replace my previous PR. While running a Leaf based app, I noticed that the CSS and JavaScript files were not being served up properly. They were returning status code 200, but contained 0 bytes. I discovered that the FileMiddleware is using streaming for the files, but the conversion from Vapor Response to Lambda response did not handle this case.
I have fixed this, but I had to change the API a little because the fix requires the use of promises and event loops.
I spent a little time looking into doing some tests, but that requires creating a Lambda.Context object and all the APIs I could find for doing are marked internal and are therefore inaccessible. If you have any pointers into how I might do that, I would be happy to look into creating some test requests.