Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the benefit of using http hijacker

Tags:

http

go

go-http

Go http pkg provide a Hijacker interface, can anyone tell when should I use it.

I check the comment, after a Hijack call lets the caller take over the connection, the HTTP server library will not do anything else with the connection.

I understand it as it's used to support both http request and common tcp interactive within one port. Is it right? Does it has any other benefits.

like image 929
carter2000 Avatar asked Jun 27 '13 03:06

carter2000


1 Answers

It means that you take over the control of TCP connection. TCP is a generic transport protocol, whereas HTTP is an application protocol on top of TCP. The OSI seven layer model describes TCP as layer 4 and HTTP is layer 7.

If you need to implement a different application protocol, this is one use-case for hijacking.

Or if you need to do something specialised with HTTP, like preventing keep-alive connections, that is another use-case.

An example for an alternative web application protocol is Google's SPDY. It's also a good reason why you might hijack an existing HTTP connection, rather than create a TCP connection directly. For SPDY, a browser would first make an HTTP request that included 'accept' headers indicating that it is also able to understand SPDY. So now you could hijack the connection and implement SPDY instead of HTTP.

like image 98
fmt.Println.MKO Avatar answered Oct 13 '22 17:10

fmt.Println.MKO