Skip to content
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

[feature] send blob response #5139

Closed
wants to merge 37 commits into from

Conversation

debadutta98
Copy link

@debadutta98 debadutta98 commented Mar 5, 2023

Hi @dougwilson and Team

I hope this improves the feature of express 🚀🚀

This PR is related to #4807

  • Send blob response using res.send(blob)
  • Added testcases
  • It only accept the instance of node Blob Object

Thank you 😊

@debadutta98 debadutta98 marked this pull request as draft March 5, 2023 07:43
@debadutta98 debadutta98 marked this pull request as ready for review March 5, 2023 07:44
lib/response.js Outdated Show resolved Hide resolved
lib/response.js Outdated Show resolved Hide resolved
lib/response.js Outdated Show resolved Hide resolved
lib/response.js Outdated Show resolved Hide resolved
@debadutta98
Copy link
Author

Hi @dougwilson and @abenhamdine just made some changes please verify

test/res.send.js Outdated Show resolved Hide resolved
@debadutta98
Copy link
Author

hi @dougwilson , is this PR need any further improvements or is anything still pending from the end to complete this ?

@debadutta98
Copy link
Author

hi @dougwilson, as you can see that all the test cases have been passed so can we merge this now?

lib/response.js Outdated Show resolved Hide resolved
@debadutta98
Copy link
Author

Hi @dougwilson, I think all issues reported by you are resolved. hope to merge this soon.

Thank you!!

@debadutta98
Copy link
Author

Hi @dougwilson, can you please re-run the GitHub action?
There might be an issue with the test run.

Thank you !!

@debadutta98
Copy link
Author

@dougwilson is there any issues which is still there in this PR?

@debadutta98
Copy link
Author

@dougwilson just to remind you about this.

Copy link
Contributor

@krzysdz krzysdz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that your code populates Content-Length in the switch/case where the type is set for all types of arguments and you skip the populate Content-Length blocks. This means that ETag will never be set. I assume that this is on purpose, because the etag package does not work with Blobs and Files.

Maybe it would be worth considering adding support for Blob/File to etag first?
The problem is that the crypto.Hash API requires a string, Buffer, TypedArray or DataView and that would require calling blob.arrayBuffer(), which copies the data (and is asynchronous). For Files, however, a tag based on size and lastModified could be used like for regular files.

Also, your code formatting is inconsistent (sometimes lacking spaces between if and ( or ) and {; semicolons are used most of the time, but not always), but this is just nitpicking, especially since the existing code does not adhere to the JavaScript Standard Style (required by the Express Collaborator Guide) either.

test/res.send.js Outdated Show resolved Hide resolved
lib/response.js Outdated Show resolved Hide resolved
@debadutta98
Copy link
Author

I see that your code populates Content-Length in the switch/case where the type is set for all types of arguments and you skip the populate Content-Length blocks. This means that ETag will never be set. I assume that this is on purpose, because the etag package does not work with Blobs and Files.

Maybe it would be worth considering adding support for Blob/File to etag first? The problem is that the crypto.Hash API requires a string, Buffer, TypedArray or DataView and that would require calling blob.arrayBuffer(), which copies the data (and is asynchronous). For Files, however, a tag based on size and lastModified could be used like for regular files.

Also, your code formatting is inconsistent (sometimes lacking spaces between if and ( or ) and {; semicolons are used most of the time, but not always), but this is just nitpicking, especially since the existing code does not adhere to the JavaScript Standard Style (required by the Express Collaborator Guide) either.

Hi @krzysdz, I don't find any lint issue or something like that on this particular piece of code that I have written here by running npm run lint if find any please make your review comment on this I will check it out.

@debadutta98
Copy link
Author

debadutta98 commented Jun 30, 2023

Hi @dougwilson @krzysdz and Team
Implementing etag mechanism for the cache control will take a lot of time to configure on this module. so can we need to raise a different issue of etag support for Blob and File streaming or should we make it happen on this PR? if we need to implement it on this PR can we discuss how we are going to achieve this before implementation?

@krzysdz
Copy link
Contributor

krzysdz commented Jun 30, 2023

Blob support for etag is definitely out-of-scope for this PR, since it is a separate package (jshttp/etag) and, as I already wrote, it may not be possible to do efficiently (or at all without significant changes to its API). While the lack of ETag for Blob is not a breaking change, since Blobs aren't supported yet in Express, it is something that others may found confusing, because ETag is generated for all other types of arguments. Ultimately, it's up for @dougwilson to decide, whether the omission of ETag for Blob is acceptable.

As for the code style, npm run lint executes eslint, which does not perform many checks (see .eslintrc.yml). The code style referred to in the the Express Collaborator Guide has many more rules which are not verified and not always followed in the existing code.

@debadutta98
Copy link
Author

Hi @dougwilson, can you please give some time to this PR?

@debadutta98
Copy link
Author

@dougwilson Ping

@debadutta98 debadutta98 closed this Aug 6, 2023
@debadutta98 debadutta98 reopened this Apr 21, 2024
@debadutta98
Copy link
Author

@UlisesGascon , Could you please review this pull request and merge it if everything looks good? If there are any areas that need improvement, could you let me know?

@UlisesGascon UlisesGascon requested review from a team and removed request for dougwilson, jimmywarting, abenhamdine, krzysdz and triyanox April 21, 2024 10:11
@wesleytodd
Copy link
Member

This is a long thread (mostly with the OP spamming 😭, please stop spamming maintainers), AFAICT the comment with the most context is from @jimmywarting which seems to me to conclude that this feature is not really necessary for anything other than in node 14.

Unless anyone else can summarize it in a digestible way with a clear argument in favor of adding support for this I am a 👎 on landing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants