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
6da0cdb9
authored
2015-04-26 15:24:04 +0800
by
JessonChan
Committed by
astaxie
2015-05-25 09:10:37 +0800
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
no need lock here
1 parent
9f070c62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
9 deletions
httplib/httplib.go
httplib/httplib.go
View file @
6da0cdb
...
...
@@ -47,26 +47,20 @@ import (
"net/url"
"os"
"strings"
"sync"
"time"
)
var
defaultSetting
=
BeegoHttpSettings
{
UserAgent
:
"beegoServer"
,
ConnectTimeout
:
60
*
time
.
Second
,
ReadWriteTimeout
:
60
*
time
.
Second
,
Gzip
:
true
}
var
defaultCookieJar
http
.
CookieJar
var
settingMutex
sync
.
Mutex
// createDefaultCookie creates a global cookiejar to store cookies.
func
createDefaultCookie
()
{
settingMutex
.
Lock
()
defaultCookieJar
,
_
=
cookiejar
.
New
(
nil
)
settingMutex
.
Unlock
()
}
// Overwrite default settings
func
SetDefaultSetting
(
setting
BeegoHttpSettings
)
{
settingMutex
.
Lock
()
defaultSetting
=
setting
settingMutex
.
Unlock
()
}
// return *BeegoHttpRequest with specific method
...
...
@@ -82,7 +76,7 @@ func newBeegoRequest(url, method string) *BeegoHttpRequest {
return
&
BeegoHttpRequest
{
url
:
url
,
req
:
&
req
,
params
:
map
[
string
]
string
{},
params
:
map
[
string
]
string
{},
files
:
map
[
string
]
string
{},
setting
:
defaultSetting
,
resp
:
&
resp
,
...
...
@@ -256,11 +250,11 @@ func (b *BeegoHttpRequest) PostFile(formname, filename string) *BeegoHttpRequest
// it supports string and []byte.
func
(
b
*
BeegoHttpRequest
)
Body
(
data
interface
{})
*
BeegoHttpRequest
{
switch
t
:=
data
.
(
type
)
{
case
string
:
case
string
:
bf
:=
bytes
.
NewBufferString
(
t
)
b
.
req
.
Body
=
ioutil
.
NopCloser
(
bf
)
b
.
req
.
ContentLength
=
int64
(
len
(
t
))
case
[]
byte
:
case
[]
byte
:
bf
:=
bytes
.
NewBuffer
(
t
)
b
.
req
.
Body
=
ioutil
.
NopCloser
(
bf
)
b
.
req
.
ContentLength
=
int64
(
len
(
t
))
...
...
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