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
7eaecb89
Commit
7eaecb89
authored
Mar 01, 2011
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: export parseHTTPVersion.
R=rsc, adg CC=golang-dev
https://golang.org/cl/4244045
parent
4b0ecd3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
src/pkg/http/request.go
src/pkg/http/request.go
+4
-4
src/pkg/http/response.go
src/pkg/http/response.go
+1
-1
No files found.
src/pkg/http/request.go
View file @
7eaecb89
...
...
@@ -315,8 +315,9 @@ func atoi(s string, i int) (n, i1 int, ok bool) {
return
n
,
i
,
true
}
// Parse HTTP version: "HTTP/1.2" -> (1, 2, true).
func
parseHTTPVersion
(
vers
string
)
(
int
,
int
,
bool
)
{
// ParseHTTPVersion parses a HTTP version string.
// "HTTP/1.2" returns (1, 2, true).
func
ParseHTTPVersion
(
vers
string
)
(
major
,
minor
int
,
ok
bool
)
{
if
len
(
vers
)
<
5
||
vers
[
0
:
5
]
!=
"HTTP/"
{
return
0
,
0
,
false
}
...
...
@@ -324,7 +325,6 @@ func parseHTTPVersion(vers string) (int, int, bool) {
if
!
ok
||
i
>=
len
(
vers
)
||
vers
[
i
]
!=
'.'
{
return
0
,
0
,
false
}
var
minor
int
minor
,
i
,
ok
=
atoi
(
vers
,
i
+
1
)
if
!
ok
||
i
!=
len
(
vers
)
{
return
0
,
0
,
false
...
...
@@ -416,7 +416,7 @@ func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) {
}
req
.
Method
,
req
.
RawURL
,
req
.
Proto
=
f
[
0
],
f
[
1
],
f
[
2
]
var
ok
bool
if
req
.
ProtoMajor
,
req
.
ProtoMinor
,
ok
=
p
arseHTTPVersion
(
req
.
Proto
);
!
ok
{
if
req
.
ProtoMajor
,
req
.
ProtoMinor
,
ok
=
P
arseHTTPVersion
(
req
.
Proto
);
!
ok
{
return
nil
,
&
badStringError
{
"malformed HTTP version"
,
req
.
Proto
}
}
...
...
src/pkg/http/response.go
View file @
7eaecb89
...
...
@@ -106,7 +106,7 @@ func ReadResponse(r *bufio.Reader, requestMethod string) (resp *Response, err os
resp
.
Proto
=
f
[
0
]
var
ok
bool
if
resp
.
ProtoMajor
,
resp
.
ProtoMinor
,
ok
=
p
arseHTTPVersion
(
resp
.
Proto
);
!
ok
{
if
resp
.
ProtoMajor
,
resp
.
ProtoMinor
,
ok
=
P
arseHTTPVersion
(
resp
.
Proto
);
!
ok
{
return
nil
,
&
badStringError
{
"malformed HTTP version"
,
resp
.
Proto
}
}
...
...
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