good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
websocket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
websocket
Commits
fdc40791
Unverified
Commit
fdc40791
authored
4 years ago
by
Andy Bursavich
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Clone options (#259)
See:
https://staticcheck.io/docs/checks#SA4001
parent
897a5732
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
accept.go
+9
-5
9 additions, 5 deletions
accept.go
dial.go
+15
-11
15 additions, 11 deletions
dial.go
with
24 additions
and
16 deletions
accept.go
+
9
−
5
View file @
fdc40791
...
...
@@ -63,6 +63,14 @@ type AcceptOptions struct {
CompressionThreshold
int
}
func
(
opts
*
AcceptOptions
)
cloneWithDefaults
()
*
AcceptOptions
{
var
o
AcceptOptions
if
opts
!=
nil
{
o
=
*
opts
}
return
&
o
}
// Accept accepts a WebSocket handshake from a client and upgrades the
// the connection to a WebSocket.
//
...
...
@@ -77,17 +85,13 @@ func Accept(w http.ResponseWriter, r *http.Request, opts *AcceptOptions) (*Conn,
func
accept
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
opts
*
AcceptOptions
)
(
_
*
Conn
,
err
error
)
{
defer
errd
.
Wrap
(
&
err
,
"failed to accept WebSocket connection"
)
if
opts
==
nil
{
opts
=
&
AcceptOptions
{}
}
opts
=
&*
opts
errCode
,
err
:=
verifyClientRequest
(
w
,
r
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
errCode
)
return
nil
,
err
}
opts
=
opts
.
cloneWithDefaults
()
if
!
opts
.
InsecureSkipVerify
{
err
=
authenticateOrigin
(
r
,
opts
.
OriginPatterns
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
dial.go
+
15
−
11
View file @
fdc40791
...
...
@@ -47,6 +47,20 @@ type DialOptions struct {
CompressionThreshold
int
}
func
(
opts
*
DialOptions
)
cloneWithDefaults
()
*
DialOptions
{
var
o
DialOptions
if
opts
!=
nil
{
o
=
*
opts
}
if
o
.
HTTPClient
==
nil
{
o
.
HTTPClient
=
http
.
DefaultClient
}
if
o
.
HTTPHeader
==
nil
{
o
.
HTTPHeader
=
http
.
Header
{}
}
return
&
o
}
// Dial performs a WebSocket handshake on url.
//
// The response is the WebSocket handshake response from the server.
...
...
@@ -67,17 +81,7 @@ func Dial(ctx context.Context, u string, opts *DialOptions) (*Conn, *http.Respon
func
dial
(
ctx
context
.
Context
,
urls
string
,
opts
*
DialOptions
,
rand
io
.
Reader
)
(
_
*
Conn
,
_
*
http
.
Response
,
err
error
)
{
defer
errd
.
Wrap
(
&
err
,
"failed to WebSocket dial"
)
if
opts
==
nil
{
opts
=
&
DialOptions
{}
}
opts
=
&*
opts
if
opts
.
HTTPClient
==
nil
{
opts
.
HTTPClient
=
http
.
DefaultClient
}
if
opts
.
HTTPHeader
==
nil
{
opts
.
HTTPHeader
=
http
.
Header
{}
}
opts
=
opts
.
cloneWithDefaults
()
secWebSocketKey
,
err
:=
secWebSocketKey
(
rand
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment