Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use the same DialOptions for WASM and non-WASM#473

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
flimzy wants to merge1 commit intocoder:master
base:master
Choose a base branch
Loading
fromflimzy:wasmOptions
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletionsdial.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,36 +20,6 @@ import (
"github.com/coder/websocket/internal/errd"
)

// DialOptions represents Dial's options.
type DialOptions struct {
// HTTPClient is used for the connection.
// Its Transport must return writable bodies for WebSocket handshakes.
// http.Transport does beginning with Go 1.12.
HTTPClient *http.Client

// HTTPHeader specifies the HTTP headers included in the handshake request.
HTTPHeader http.Header

// Host optionally overrides the Host HTTP header to send. If empty, the value
// of URL.Host will be used.
Host string

// Subprotocols lists the WebSocket subprotocols to negotiate with the server.
Subprotocols []string

// CompressionMode controls the compression mode.
// Defaults to CompressionDisabled.
//
// See docs on CompressionMode for details.
CompressionMode CompressionMode

// CompressionThreshold controls the minimum size of a message before compression is applied.
//
// Defaults to 512 bytes for CompressionNoContextTakeover and 128 bytes
// for CompressionContextTakeover.
CompressionThreshold int
}

func (opts *DialOptions) cloneWithDefaults(ctx context.Context) (context.Context, context.CancelFunc, *DialOptions) {
var cancel context.CancelFunc

Expand Down
36 changes: 36 additions & 0 deletionsws.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
package websocket // import "github.com/coder/websocket"

import "net/http"

// DialOptions represents Dial's options.
//
// Note that when building for WebAssembly, the following fields are ignored:
// HTTPClient, HTTPHeader, Host, CompressionMode, CompressionThreshold.
type DialOptions struct {
// HTTPClient is used for the connection.
// Its Transport must return writable bodies for WebSocket handshakes.
// http.Transport does beginning with Go 1.12.
HTTPClient *http.Client

// HTTPHeader specifies the HTTP headers included in the handshake request.
HTTPHeader http.Header

// Host optionally overrides the Host HTTP header to send. If empty, the value
// of URL.Host will be used.
Host string

// Subprotocols lists the WebSocket subprotocols to negotiate with the server.
Subprotocols []string

// CompressionMode controls the compression mode.
// Defaults to CompressionDisabled.
//
// See docs on CompressionMode for details.
CompressionMode CompressionMode

// CompressionThreshold controls the minimum size of a message before compression is applied.
//
// Defaults to 512 bytes for CompressionNoContextTakeover and 128 bytes
// for CompressionContextTakeover.
CompressionThreshold int
}
6 changes: 0 additions & 6 deletionsws_js.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -277,12 +277,6 @@ func (c *Conn) Subprotocol() string {
return c.ws.Subprotocol()
}

// DialOptions represents the options available to pass to Dial.
type DialOptions struct {
// Subprotocols lists the subprotocols to negotiate with the server.
Subprotocols []string
}

// Dial creates a new WebSocket connection to the given url with the given options.
// The passed context bounds the maximum time spent waiting for the connection to open.
// The returned *http.Response is always nil or a mock. It's only in the signature
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp