//go:build windows package yu_curl import ( "errors" yu_http "gogs.qqck.cn/s/tools/http" ) func (t *Request) resp_reset() { t.resp_body = nil t.resp_headers_raw = nil t.resp_headers = make(map[string]string) t.resp_cookies = make(map[string]string) } // RespErrCode // // @Description: 获取响应状态,E_OK 为成功,其他错误参考 E_ func (t *Request) RespErrCode() uintptr { return t.perform } // RespErr // // @Description: 获取响应错误信息,nil 为成功 func (t *Request) RespErr() error { if t.perform == E_OK { return nil } return errors.New(curl_easy_strerror.CallGbkToUtf8(t.perform)) } // -----------------------------------------------------------------------------------------------------------------------------------------------Content-Type // RespContentType // // @Description: 响应"Content-Type"类型 func (t *Request) RespContentType() (v string) { return t.resp_headers["Content-Type"] } // -----------------------------------------------------------------------------------------------------------------------------------------------Cookies // RespCookie // // @Description: 获取单个响应 Cookie func (t *Request) RespCookie(name string) string { return t.resp_cookies[name] } // RespCookies // // @Description: 获取全部响应 Cookie func (t *Request) RespCookies() string { if len(t.resp_cookies) == 0 { return "" } j_cookies := make([]byte, 0, 1024) for j_name, j_value := range t.resp_cookies { j_cookies = append(j_cookies, j_name...) j_cookies = append(j_cookies, '=') j_cookies = append(j_cookies, j_value...) j_cookies = append(j_cookies, ';') j_cookies = append(j_cookies, ' ') } return string(j_cookies) } // -----------------------------------------------------------------------------------------------------------------------------------------------Headers // RespHeader // // @Description: 获取单个响应 Header func (t *Request) RespHeader(name string) string { name = yu_http.Normalize(name) if name == "Cookie" { return t.RespCookies() } else { return t.resp_headers[name] } } // RespHeaders // // @Description: 获取全部响应 Headers func (t *Request) RespHeaders() string { if len(t.resp_headers) == 0 { return "" } j_headers := make([]byte, 0, 4096) for j_name, j_value := range t.resp_headers { j_headers = append(j_headers, j_name...) j_headers = append(j_headers, ':') j_headers = append(j_headers, ' ') j_headers = append(j_headers, j_value...) j_headers = append(j_headers, 13, 10) } return string(j_headers) } // RespHeadersRaw // // @Description: 获取全部响应原始 Headers 数据 func (t *Request) RespHeadersRaw() string { return string(t.resp_headers_raw) } // -----------------------------------------------------------------------------------------------------------------------------------------------Utils // RespStatusCode // // @Description: 获取响应 HTTP 状态码 func (t *Request) RespStatusCode() int { j_result := 0 t.perform, _, _ = curl_easy_getinfo.Call(t.curl, INFO_RESPONSE_CODE, &j_result) return j_result } // RespLen // // @Description: 获取响应数据尺寸 func (t *Request) RespLen() int { return len(t.resp_body) } // RespBody // // @Description: 获取响应数据 func (t *Request) RespBody() []byte { return t.resp_body } // RespBodyS // // @Description: 获取响应数据 func (t *Request) RespBodyS() string { return string(t.resp_body) }