Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

steam 响应处理建议 #68

Open
bincooo opened this issue Jun 27, 2024 · 0 comments
Open

steam 响应处理建议 #68

bincooo opened this issue Jun 27, 2024 · 0 comments

Comments

@bincooo
Copy link

bincooo commented Jun 27, 2024

你好,可否在遇到stream响应头时不要读取body?

func (s *Session) buildResponse(resp *http.Response, preq *models.PrepareRequest, req *url.Request) (*models.Response, error) {

stream := strings.Contains(resp.Header.Get("Content-Type"), "application/stream") ||
		strings.Contains(resp.Header.Get("Content-Type"), "text/event-stream")

if stream {
        response := &models.Response{
	        Url:        preq.Url,
	        Headers:    resp.Header,
	        Cookies:    resp.Cookies(),
	        Text:       "",
	        Content:    nil,
	        Body:       resp.Body,
	        StatusCode: resp.StatusCode,
	        History:    []*models.Response{},
	        Request:    req,
        }
        if resp.Cookies() != nil {
	        u, _ := url2.Parse(preq.Url)
	        s.Cookies.SetCookies(u, resp.Cookies())
        }
        return response, nil
}

这应该还缺了编码处理,可添加这部分处理进项目嘛 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant