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

Add Note for WebSocket subprotocols #1164

Merged
merged 3 commits into from
Aug 26, 2024
Merged

Conversation

shugen002
Copy link
Contributor

@shugen002 shugen002 commented Aug 20, 2024

Sorry for my poor English....

Summary by CodeRabbit

  • Documentation
    • Added detailed information on handling WebSocket subprotocols to the README.md, clarifying configuration, negotiation, and connection behavior.

@shugen002 shugen002 requested a review from a team as a code owner August 20, 2024 22:12
@shugen002 shugen002 requested review from gaby, sixcolors, ReneWerner87 and efectn and removed request for a team August 20, 2024 22:12
Copy link
Contributor

coderabbitai bot commented Aug 20, 2024

Walkthrough

The recent updates to the websocket module's README.md enhance the guidance on handling WebSocket subprotocols. The new section details the configuration of subprotocol negotiation, the significance of the Sec-Websocket-Protocol header, and the behavior of connections based on negotiation success. This addition enriches user understanding of connection management and subprotocol retrieval, ensuring clearer documentation for developers.

Changes

File Change Summary
websocket/README.md Added a section on WebSocket subprotocol handling, explaining the configuration for Subprotocols, negotiation outcomes, and connection behavior.

Poem

In the meadow, hops a bunny bright,
With changes in websockets, oh what a delight!
Subprotocols dance, headers in flight,
Connections now clearer, all set for the night.
With each byte and hop, we cheer and we play,
For smoother connections, hip-hip-hooray! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (1)
websocket/README.md (1)

153-153: Clarify sentence structure for better understanding.

The sentence structure is awkward and can be improved for clarity. Consider rephrasing it.

Here's a suggested rephrasing:

- If there is a connection with `Sec-Websocket-Protocol` header in the request with failed negotitation, the connection will be disconnected by browser after received upgrade response immediately.
+ If a connection request includes a `Sec-Websocket-Protocol` header but the negotiation fails, the browser will immediately disconnect the connection after receiving the upgrade response.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c62abb2 and e4f7c78.

Files selected for processing (1)
  • websocket/README.md (1 hunks)
Additional context used
LanguageTool
websocket/README.md

[grammar] ~149-~149: The pronoun ‘you’ must be used with a non-third-person form of a verb.
Context: ...The config Subprotocols only help you negotiates subprotocol and set a `Sec-Websocket-Pr...

(NON3PRS_VERB)


[grammar] ~149-~149: It seems that a pronoun is missing.
Context: ...d set a Sec-Websocket-Protocol header if has a suitable subprotocol. For more ab...

(IF_VB)


[grammar] ~151-~151: There may an error in the verb form ‘be send’.
Context: ...socket#Upgrader) . All connection will be send to handler function no matter the subpr...

(MD_BE_NON_VBP)

websocket/README.md Outdated Show resolved Hide resolved
websocket/README.md Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (3)
websocket/README.md (3)

149-149: Correct grammatical errors for clarity.

The sentence contains grammatical errors that affect readability. Consider the following corrections:

  • Change "negotiates process" to "negotiation process".
  • Add a comma after "fasthttp.Upgrader" for better readability.

Here's the corrected sentence:

- The config `Subprotocols` only helps you negotiate subprotocols and sets a `Sec-Websocket-Protocol` header if it has a suitable subprotocol. For more about negotiates process, check the comment for `Subprotocols` in [fasthttp.Upgrader](https://pkg.go.dev/github.com/fasthttp/websocket#Upgrader) .
+ The config `Subprotocols` only helps you negotiate subprotocols and sets a `Sec-Websocket-Protocol` header if it has a suitable subprotocol. For more about the negotiation process, check the comment for `Subprotocols` in [fasthttp.Upgrader](https://pkg.go.dev/github.com/fasthttp/websocket#Upgrader).

151-151: Consider adding a comma for better readability.

Adding a comma after "no matter" can improve the readability of the sentence.

- All connections will be sent to the handler function no matter whether the subprotocol negotiation is successful or not.
+ All connections will be sent to the handler function, no matter whether the subprotocol negotiation is successful or not.
Tools
LanguageTool

[typographical] ~151-~151: Consider adding a comma here.
Context: ...ons will be sent to the handler function no matter whether the subprotocol negotiat...

(NO_MATTER_COMMA)


153-153: Fix typographical errors for clarity.

The sentence contains a typographical error. Consider the following corrections:

  • Change "negotitation" to "negotiation".
  • Change "after received upgrade response immediately" to "immediately after receiving the upgrade response".

Here's the corrected sentence:

- If there is a connection with `Sec-Websocket-Protocol` header in the request with failed negotitation, the connection will be disconnected by browser after received upgrade response immediately.
+ If there is a connection with a `Sec-Websocket-Protocol` header in the request with a failed negotiation, the connection will be disconnected by the browser immediately after receiving the upgrade response.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e4f7c78 and 9dbcc11.

Files selected for processing (1)
  • websocket/README.md (1 hunks)
Additional context used
LanguageTool
websocket/README.md

[typographical] ~151-~151: Consider adding a comma here.
Context: ...ons will be sent to the handler function no matter whether the subprotocol negotiat...

(NO_MATTER_COMMA)

@gaby
Copy link
Member

gaby commented Aug 21, 2024

@coderabbitai full review

Copy link
Contributor

coderabbitai bot commented Aug 21, 2024

Actions performed

Full review triggered.

@gaby gaby added the 📒 Documentation Improvements or additions to documentation label Aug 21, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (3)
websocket/README.md (3)

149-149: Correct grammatical errors for clarity.

The sentence contains grammatical errors that affect readability. Consider the following corrections:

  • Change "negotiates process" to "negotiation process".
  • Add a comma after "subprotocols" to improve readability.

Here's the corrected sentence:

- The config `Subprotocols` only helps you negotiate subprotocols and sets a `Sec-Websocket-Protocol` header if it has a suitable subprotocol. For more about negotiates process, check the comment for `Subprotocols` in [fasthttp.Upgrader](https://pkg.go.dev/github.com/fasthttp/websocket#Upgrader) .
+ The config `Subprotocols` only helps you negotiate subprotocols and sets a `Sec-Websocket-Protocol` header if it has a suitable subprotocol. For more about the negotiation process, check the comment for `Subprotocols` in [fasthttp.Upgrader](https://pkg.go.dev/github.com/fasthttp/websocket#Upgrader).

151-151: Add a comma for improved readability.

Consider adding a comma after "no matter" to clarify the sentence structure.

Here's the corrected sentence:

- All connections will be sent to the handler function no matter whether the subprotocol negotiation is successful or not. You can get the selected subprotocol from `conn.Subprotocol()`.
+ All connections will be sent to the handler function, no matter whether the subprotocol negotiation is successful or not. You can get the selected subprotocol from `conn.Subprotocol()`.
Tools
LanguageTool

[typographical] ~151-~151: Consider adding a comma here.
Context: ...ons will be sent to the handler function no matter whether the subprotocol negotiat...

(NO_MATTER_COMMA)


153-153: Correct typographical error and clarify the sentence.

The sentence contains a typographical error and could be clearer. Consider the following corrections:

  • Change "negotitation" to "negotiation".
  • Clarify the sequence of events regarding the browser's behavior.

Here's the corrected sentence:

- If there is a connection with `Sec-Websocket-Protocol` header in the request with failed negotitation, the connection will be disconnected by browser after received upgrade response immediately.
+ If a connection request includes a `Sec-Websocket-Protocol` header but fails negotiation, the browser will immediately disconnect the connection after receiving the upgrade response.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c62abb2 and 9dbcc11.

Files selected for processing (1)
  • websocket/README.md (1 hunks)
Additional context used
LanguageTool
websocket/README.md

[typographical] ~151-~151: Consider adding a comma here.
Context: ...ons will be sent to the handler function no matter whether the subprotocol negotiat...

(NO_MATTER_COMMA)

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM

websocket/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
websocket/README.md (2)

151-151: Consider adding a comma for clarity.

Add a comma after "no matter" for improved readability.

- All connections will be sent to the handler function no matter whether the subprotocol negotiation is successful or not.
+ All connections will be sent to the handler function, no matter whether the subprotocol negotiation is successful or not.
Tools
LanguageTool

[typographical] ~151-~151: Consider adding a comma here.
Context: ...ons will be sent to the handler function no matter whether the subprotocol negotiat...

(NO_MATTER_COMMA)


153-153: Add a comma before "but" for grammatical correctness.

Add a comma before "but" to separate the independent clauses.

- If a connection includes the `Sec-Websocket-Protocol` header in the request but the protocol negotiation fails, the browser will immediately disconnect the connection after receiving the upgrade response.
+ If a connection includes the `Sec-Websocket-Protocol` header in the request, but the protocol negotiation fails, the browser will immediately disconnect the connection after receiving the upgrade response.
Tools
LanguageTool

[uncategorized] ~153-~153: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ebsocket-Protocol` header in the request but the protocol negotiation fails, the bro...

(COMMA_COMPOUND_SENTENCE_2)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9dbcc11 and a8b65e7.

Files selected for processing (1)
  • websocket/README.md (1 hunks)
Additional context used
LanguageTool
websocket/README.md

[typographical] ~151-~151: Consider adding a comma here.
Context: ...ons will be sent to the handler function no matter whether the subprotocol negotiat...

(NO_MATTER_COMMA)


[uncategorized] ~153-~153: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ebsocket-Protocol` header in the request but the protocol negotiation fails, the bro...

(COMMA_COMPOUND_SENTENCE_2)

Additional comments not posted (1)
websocket/README.md (1)

147-147: New section added: "Note for WebSocket subprotocols".

The addition of this section provides valuable information about handling WebSocket subprotocols.

@ReneWerner87 ReneWerner87 dismissed sixcolors’s stale review August 26, 2024 06:24

Everything is solved

@ReneWerner87 ReneWerner87 merged commit 18e5577 into gofiber:main Aug 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📒 Documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants