Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
647a4751
authored
2014-09-05 23:21:41 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
httplib: fix the header function for User-Agent
1 parent
f7cd1479
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
httplib/httplib.go
httplib/httplib_test.go
httplib/httplib.go
View file @
647a475
...
...
@@ -355,7 +355,7 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
Jar
:
jar
,
}
if
b
.
setting
.
UserAgent
!=
""
{
if
b
.
setting
.
UserAgent
!=
""
&&
b
.
req
.
Header
.
Get
(
"User-Agent"
)
==
""
{
b
.
req
.
Header
.
Set
(
"User-Agent"
,
b
.
setting
.
UserAgent
)
}
...
...
httplib/httplib_test.go
View file @
647a475
...
...
@@ -203,3 +203,13 @@ func TestToFile(t *testing.T) {
t
.
Fatal
(
err
)
}
}
func
TestHeader
(
t
*
testing
.
T
)
{
req
:=
Get
(
"http://httpbin.org/headers"
)
req
.
Header
(
"User-Agent"
,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"
)
str
,
err
:=
req
.
String
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
t
.
Log
(
str
)
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment