add ci for setting headers

This commit is contained in:
fatedier
2018-05-20 23:55:22 +08:00
parent cf4136fe99
commit 2e497274ba
6 changed files with 41 additions and 18 deletions

View File

@@ -126,7 +126,7 @@ func sendUdpMsg(addr string, msg string) (res string, err error) {
return string(buf[:n]), nil
}
func sendHttpMsg(method, urlStr string, host string, header map[string]string, proxy string) (code int, body string, err error) {
func sendHttpMsg(method, urlStr string, host string, headers map[string]string, proxy string) (code int, body string, header http.Header, err error) {
req, errRet := http.NewRequest(method, urlStr, nil)
if errRet != nil {
err = errRet
@@ -136,7 +136,7 @@ func sendHttpMsg(method, urlStr string, host string, header map[string]string, p
if host != "" {
req.Host = host
}
for k, v := range header {
for k, v := range headers {
req.Header.Set(k, v)
}
@@ -167,6 +167,7 @@ func sendHttpMsg(method, urlStr string, host string, header map[string]string, p
return
}
code = resp.StatusCode
header = resp.Header
buf, errRet := ioutil.ReadAll(resp.Body)
if errRet != nil {
err = errRet