improve the code and delete NO NEED URL CHECK
Showing
1 changed file
with
3 additions
and
7 deletions
| ... | @@ -75,14 +75,14 @@ func SetDefaultSetting(setting BeegoHttpSettings) { | ... | @@ -75,14 +75,14 @@ func SetDefaultSetting(setting BeegoHttpSettings) { |
| 75 | 75 | ||
| 76 | // return *BeegoHttpRequest with specific method | 76 | // return *BeegoHttpRequest with specific method |
| 77 | func newBeegoRequest(url, method string) *BeegoHttpRequest { | 77 | func newBeegoRequest(url, method string) *BeegoHttpRequest { |
| 78 | var resp http.Response | ||
| 78 | req := http.Request{ | 79 | req := http.Request{ |
| 80 | Method: method, | ||
| 81 | Header: make(http.Header), | ||
| 79 | Proto: "HTTP/1.1", | 82 | Proto: "HTTP/1.1", |
| 80 | ProtoMajor: 1, | 83 | ProtoMajor: 1, |
| 81 | ProtoMinor: 1, | 84 | ProtoMinor: 1, |
| 82 | } | 85 | } |
| 83 | var resp http.Response | ||
| 84 | req.Method = method | ||
| 85 | req.Header = http.Header{} | ||
| 86 | return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil} | 86 | return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil} |
| 87 | } | 87 | } |
| 88 | 88 | ||
| ... | @@ -310,10 +310,6 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { | ... | @@ -310,10 +310,6 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | url, err := url.Parse(b.url) | 312 | url, err := url.Parse(b.url) |
| 313 | if url.Scheme == "" { | ||
| 314 | b.url = "http://" + b.url | ||
| 315 | url, err = url.Parse(b.url) | ||
| 316 | } | ||
| 317 | if err != nil { | 313 | if err != nil { |
| 318 | return nil, err | 314 | return nil, err |
| 319 | } | 315 | } | ... | ... |
-
Please register or sign in to post a comment