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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
github
nhooyr
websocket
Commits
dbaf6f8f
Commit
dbaf6f8f
authored
Sep 24, 2020
by
swithek
Browse files
Options
Downloads
Patches
Plain Diff
Create context with http client timeout
parent
1b61eb0b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dial.go
+5
-2
5 additions, 2 deletions
dial.go
with
5 additions
and
2 deletions
dial.go
+
5
−
2
View file @
dbaf6f8f
...
...
@@ -25,7 +25,6 @@ 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.
// Non-zero timeout will be ignored, see https://github.com/nhooyr/websocket/issues/67.
HTTPClient
*
http
.
Client
// HTTPHeader specifies the HTTP headers included in the handshake request.
...
...
@@ -75,7 +74,11 @@ func dial(ctx context.Context, urls string, opts *DialOptions, rand io.Reader) (
if
opts
.
HTTPClient
==
nil
{
opts
.
HTTPClient
=
http
.
DefaultClient
}
else
if
opts
.
HTTPClient
.
Timeout
>
0
{
// remove timeout
var
cancel
context
.
CancelFunc
ctx
,
cancel
=
context
.
WithTimeout
(
ctx
,
opts
.
HTTPClient
.
Timeout
)
defer
cancel
()
opts
.
HTTPClient
=
&
http
.
Client
{
Transport
:
opts
.
HTTPClient
.
Transport
,
CheckRedirect
:
opts
.
HTTPClient
.
CheckRedirect
,
...
...
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