8

Go language http connection hijacking.

I know how to hijack on server side. http://golang.org/pkg/net/http/#example_Hijacker

But is there way to hijack it on clients side?

2
  • Not really (connections are pooled in the Transport). What is it you actually need to do? Commented May 22, 2014 at 18:28
  • I have go_client and go_server. Go_server is web server. I wish client to connect go_server to some handler. and after one HTTP request, communicate with it over raw socket. I wish client to hijack http connection. Of course if it is possible. e.g. one of things I could do is HTTP proxy CONNECT instead of GET. Commented May 22, 2014 at 18:53

1 Answer 1

10

No, you can't do this with the default http.Client, but net/http/httputil has a ClientConn, which is a low level http client that directly wraps a net.Conn. It's Hijack-able, and operates on standard http.Request's.

http://golang.org/pkg/net/http/httputil/#ClientConn

Also, since you control both sides, and you shouldn't see anything too unexpected, it may be easier to simply write the request yourself directly to the TCP connection (or use Request.Write() if you want to build the request that way)

Sign up to request clarification or add additional context in comments.

1 Comment

I have not tested ClientConn yet. But I believe it is the answer. Thank You

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.