Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
29e113a4
Commit
29e113a4
authored
May 09, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #597 from tobyzxj/develop
httplib support to set the protocol version for incoming requests
parents
d5d5f237
3caf1896
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
README.md
httplib/README.md
+6
-0
httplib.go
httplib/httplib.go
+17
-0
No files found.
httplib/README.md
View file @
29e113a4
...
...
@@ -73,3 +73,8 @@ httplib support mutil file upload, use `b.PostFile()`
t.Fatal(err)
}
fmt.Println(str)
## set HTTP version
some servers need to specify the protocol version of HTTP
httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1")
\ No newline at end of file
httplib/httplib.go
View file @
29e113a4
...
...
@@ -109,6 +109,23 @@ func (b *BeegoHttpRequest) Header(key, value string) *BeegoHttpRequest {
return
b
}
// Set the protocol version for incoming requests.
// Client requests always use HTTP/1.1.
func
(
b
*
BeegoHttpRequest
)
SetProtocolVersion
(
vers
string
)
*
BeegoHttpRequest
{
if
len
(
vers
)
==
0
{
vers
=
"HTTP/1.1"
}
major
,
minor
,
ok
:=
http
.
ParseHTTPVersion
(
vers
)
if
ok
{
b
.
req
.
Proto
=
vers
b
.
req
.
ProtoMajor
=
major
b
.
req
.
ProtoMinor
=
minor
}
return
b
}
// SetCookie add cookie into request.
func
(
b
*
BeegoHttpRequest
)
SetCookie
(
cookie
*
http
.
Cookie
)
*
BeegoHttpRequest
{
b
.
req
.
Header
.
Add
(
"Cookie"
,
cookie
.
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