diff --git a/dial.go b/dial.go index ad61a35d..e8b2546d 100644 --- a/dial.go +++ b/dial.go @@ -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 diff --git a/ws.go b/ws.go new file mode 100644 index 00000000..2ba66202 --- /dev/null +++ b/ws.go @@ -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 +} diff --git a/ws_js.go b/ws_js.go index 5e324c47..b6af88ea 100644 --- a/ws_js.go +++ b/ws_js.go @@ -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
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: