英文:
Go hijack client connection
问题
Go语言的HTTP连接劫持。
我知道如何在服务器端进行劫持。
http://golang.org/pkg/net/http/#example_Hijacker
但是在客户端有没有劫持的方法?
英文:
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?
答案1
得分: 9
不,你不能使用默认的http.Client
来实现这个,但是net/http/httputil
包中有一个ClientConn
,它是一个低级别的HTTP客户端,直接封装了一个net.Conn
。它可以被劫持,并且可以操作标准的http.Request
。
http://golang.org/pkg/net/http/httputil/#ClientConn
另外,由于你控制着两端,并且不应该出现太多意外情况,你可以直接将请求自己直接写入TCP连接(或者使用Request.Write()
方法来构建请求),这可能更容易一些。
英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论