Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.

Throw client.Do(req) error in postHijacked #183

Merged
merged 1 commit into from
Apr 1, 2016

Conversation

WeiZhang555
Copy link
Contributor

Related docker PR: moby/moby#21092

Sometime when client issues an http request via clientconn.Do(req),
server can send an error through hijacked http connection and close this
connection afterwards. We need to throw this error(httputil.ErrPersistEOF)
out, to let client know the connection is closed, so client can choose
to abort after reading detailed error message from hijacked connection.

Also client can ignore other kinds of errors, so it won't bring any problem.
And it will make more sense to not swallow the error.

Signed-off-by: Zhang Wei zhangwei555@huawei.com

Sometime when client issues an http request throw clientconn.Do(req),
server can send an error through hijacked http connection and close this
connection afterwards. We need to throw this error(httputil.ErrPersistEOF)
out, to let client know the connection is closed, so client can choose
to abort after reading detailed error message from hijacked connection.

Also client can ignore other kinds of errors.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
@vdemeester
Copy link
Contributor

LGTM 🐙
/cc @calavera

@@ -68,11 +68,11 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu
defer clientconn.Close()

// Server hijacks the connection, error 'connection closed' expected
clientconn.Do(req)
_, err = clientconn.Do(req)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return here before calling Hijack() if err != nil?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah that's a good point I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, hijack is still necessary. The case is, server meets an error, it sends error message via Hijacked connection then close it. Client gets an ErrPersistError, but it can still read error message from low level tcp connection.
So we need to do Hijack() even though error happened, only need to throw it out and let client choose how to handle the error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah make sence

@calavera
Copy link
Contributor

calavera commented Apr 1, 2016

LGTM

@vdemeester vdemeester merged commit 8924d69 into docker:master Apr 1, 2016
@WeiZhang555 WeiZhang555 deleted the hijack-throw-err branch April 1, 2016 11:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants