mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
sync
This commit is contained in:
10
body.go
10
body.go
@@ -122,15 +122,19 @@ func (obj *OrderMap) parseForm(ctx context.Context) (io.Reader, string, bool, er
|
||||
return nil, "", false, nil
|
||||
}
|
||||
if obj.isformPip() {
|
||||
pr, pw := pipe(ctx)
|
||||
pr, pw := io.Pipe()
|
||||
writer := multipart.NewWriter(pw)
|
||||
go func() {
|
||||
context.AfterFunc(ctx, func() {
|
||||
pr.CloseWithError(ctx.Err())
|
||||
pw.CloseWithError(ctx.Err())
|
||||
})
|
||||
err := obj.formWriteMain(writer)
|
||||
if err == nil {
|
||||
err = io.EOF
|
||||
}
|
||||
pr.CloseWitError(err)
|
||||
pw.CloseWitError(err)
|
||||
pr.CloseWithError(err)
|
||||
pw.CloseWithError(err)
|
||||
}()
|
||||
return pr, writer.FormDataContentType(), true, nil
|
||||
}
|
||||
|
||||
8
conn.go
8
conn.go
@@ -34,15 +34,19 @@ func newConn(ctx context.Context, con net.Conn, closeFunc func()) *conn {
|
||||
conn: con,
|
||||
closeFunc: closeFunc,
|
||||
}
|
||||
pr, pw := pipe(ctx)
|
||||
pr, pw := io.Pipe()
|
||||
c.r = bufio.NewReader(pr)
|
||||
c.w = bufio.NewWriter(c)
|
||||
go func() {
|
||||
context.AfterFunc(ctx, func() {
|
||||
pr.CloseWithError(ctx.Err())
|
||||
pw.CloseWithError(ctx.Err())
|
||||
})
|
||||
_, err := io.Copy(pw, c.conn)
|
||||
if c.err == nil {
|
||||
c.CloseWithError(err)
|
||||
}
|
||||
pr.CloseWitError(c.err)
|
||||
pr.CloseWithError(c.err)
|
||||
}()
|
||||
return c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user