zero timeout means wait until resp
Showing
1 changed file
with
3 additions
and
9 deletions
| ... | @@ -65,14 +65,8 @@ func createDefaultCookie() { | ... | @@ -65,14 +65,8 @@ func createDefaultCookie() { |
| 65 | // Overwrite default settings | 65 | // Overwrite default settings |
| 66 | func SetDefaultSetting(setting BeegoHttpSettings) { | 66 | func SetDefaultSetting(setting BeegoHttpSettings) { |
| 67 | settingMutex.Lock() | 67 | settingMutex.Lock() |
| 68 | defer settingMutex.Unlock() | ||
| 69 | defaultSetting = setting | 68 | defaultSetting = setting |
| 70 | if defaultSetting.ConnectTimeout == 0 { | 69 | settingMutex.Unlock() |
| 71 | defaultSetting.ConnectTimeout = 60 * time.Second | ||
| 72 | } | ||
| 73 | if defaultSetting.ReadWriteTimeout == 0 { | ||
| 74 | defaultSetting.ReadWriteTimeout = 60 * time.Second | ||
| 75 | } | ||
| 76 | } | 70 | } |
| 77 | 71 | ||
| 78 | // return *BeegoHttpRequest with specific method | 72 | // return *BeegoHttpRequest with specific method |
| ... | @@ -262,11 +256,11 @@ func (b *BeegoHttpRequest) PostFile(formname, filename string) *BeegoHttpRequest | ... | @@ -262,11 +256,11 @@ func (b *BeegoHttpRequest) PostFile(formname, filename string) *BeegoHttpRequest |
| 262 | // it supports string and []byte. | 256 | // it supports string and []byte. |
| 263 | func (b *BeegoHttpRequest) Body(data interface{}) *BeegoHttpRequest { | 257 | func (b *BeegoHttpRequest) Body(data interface{}) *BeegoHttpRequest { |
| 264 | switch t := data.(type) { | 258 | switch t := data.(type) { |
| 265 | case string: | 259 | case string: |
| 266 | bf := bytes.NewBufferString(t) | 260 | bf := bytes.NewBufferString(t) |
| 267 | b.req.Body = ioutil.NopCloser(bf) | 261 | b.req.Body = ioutil.NopCloser(bf) |
| 268 | b.req.ContentLength = int64(len(t)) | 262 | b.req.ContentLength = int64(len(t)) |
| 269 | case []byte: | 263 | case []byte: |
| 270 | bf := bytes.NewBuffer(t) | 264 | bf := bytes.NewBuffer(t) |
| 271 | b.req.Body = ioutil.NopCloser(bf) | 265 | b.req.Body = ioutil.NopCloser(bf) |
| 272 | b.req.ContentLength = int64(len(t)) | 266 | b.req.ContentLength = int64(len(t)) | ... | ... |
-
Please register or sign in to post a comment