Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
6d37724c
Commit
6d37724c
authored
Jul 30, 2010
by
Bill Neubauer
Committed by
Russ Cox
Jul 30, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
websocket: fix bug involving spaces in header keys
R=rsc, ukai CC=golang-dev
https://golang.org/cl/1669056
parent
1c4d380b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
src/pkg/websocket/client.go
src/pkg/websocket/client.go
+9
-8
src/pkg/websocket/websocket_test.go
src/pkg/websocket/websocket_test.go
+15
-0
No files found.
src/pkg/websocket/client.go
View file @
6d37724c
...
...
@@ -123,14 +123,7 @@ func generateKeyNumber() (key string, number uint32) {
// to U+0039 DIGIT NINE (9).
key
=
fmt
.
Sprintf
(
"%d"
,
product
)
// 21. Insert /spaces_n/ U+0020 SPACE characters into /key_n/ at random
// posisions.
for
i
:=
0
;
i
<
spaces
;
i
++
{
pos
:=
rand
.
Intn
(
len
(
key
)
-
1
)
+
1
key
=
key
[
0
:
pos
]
+
" "
+
key
[
pos
:
]
}
// 22. Insert between one and twelve random characters from the ranges
// 21. Insert between one and twelve random characters from the ranges
// U+0021 to U+002F and U+003A to U+007E into /key_n/ at random
// positions.
n
:=
rand
.
Intn
(
12
)
+
1
...
...
@@ -139,6 +132,14 @@ func generateKeyNumber() (key string, number uint32) {
ch
:=
secKeyRandomChars
[
rand
.
Intn
(
len
(
secKeyRandomChars
))]
key
=
key
[
0
:
pos
]
+
string
(
ch
)
+
key
[
pos
:
]
}
// 22. Insert /spaces_n/ U+0020 SPACE characters into /key_n/ at random
// positions other than the start or end of the string.
for
i
:=
0
;
i
<
spaces
;
i
++
{
pos
:=
rand
.
Intn
(
len
(
key
)
-
1
)
+
1
key
=
key
[
0
:
pos
]
+
" "
+
key
[
pos
:
]
}
return
}
...
...
src/pkg/websocket/websocket_test.go
View file @
6d37724c
...
...
@@ -143,3 +143,18 @@ func TestHTTPDraft75(t *testing.T) {
t
.
Errorf
(
"Get: got status %d"
,
r
.
StatusCode
)
}
}
func
TestTrailingSpaces
(
t
*
testing
.
T
)
{
// http://code.google.com/p/go/issues/detail?id=955
// The last runs of this create keys with trailing spaces that should not be
// generated by the client.
once
.
Do
(
startServer
)
for
i
:=
0
;
i
<
30
;
i
++
{
// body
_
,
err
:=
Dial
(
fmt
.
Sprintf
(
"ws://%s/echo"
,
serverAddr
),
""
,
"http://localhost/"
)
if
err
!=
nil
{
panic
(
"Dial failed: "
+
err
.
String
())
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment