MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / readResponse

Function readResponse

dialer/h1.go:160–181  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

158)
159
160func readResponse(r io.Reader) (*http.Response, error) {
161 var respBuf bytes.Buffer
162 b := make([]byte, 1)
163 for !bytes.HasSuffix(respBuf.Bytes(), responseTerminator) {
164 n, err := r.Read(b)
165 if err != nil {
166 return nil, fmt.Errorf("unable to read HTTP response: %w", err)
167 }
168 if n == 0 {
169 continue
170 }
171 _, err = respBuf.Write(b)
172 if err != nil {
173 return nil, fmt.Errorf("unable to store byte into buffer: %w", err)
174 }
175 }
176 resp, err := http.ReadResponse(bufio.NewReader(&respBuf), nil)
177 if err != nil {
178 return nil, fmt.Errorf("unable to decode proxy response: %w", err)
179 }
180 return resp, nil
181}
182
183func basicAuthHeader(userinfo *url.Userinfo) string {
184 username := userinfo.Username()

Callers 2

DialContextMethod · 0.85
ReadMethod · 0.85

Calls 3

ErrorfMethod · 0.80
ReadMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected