Was the HTTP request received over TCP or UDP?

Is there a way in Java to know if a request was received HTTP

for TCP

or more UDP

?

+3


source to share


2 answers


Quote from RFC2616

HTTP communication usually occurs over TCP / IP connections. the default port is TCP 80 [19], but other ports can be used. This does not preclude the possibility of HTTP running over any other protocol on the Internet or on other networks. HTTP only assumes reliable transport ; any protocol providing such guarantees can be used; The mapping of HTTP / 1.1 request and response structures to transport data units of the protocol under consideration is outside the scope of this specification.



I would say this removes UDP by default. Other reliable forms of protocols will still be possible

+4


source


As @ceekay reports, the RFC says that HTTP only uses reliable transport, so this means there is no way for UDP. But you can try to build some other protocol on top of UDP or not use the TCP / IP stack at all. But since your question is about Java, then the answer is all about Java libraries and frameworks used. Actually all libraries I know, like HtmlUnit http://htmlunit.sourceforge.net , hide this information from you. So you are dealing with HTTP (s) without knowing the details of underground transport. But it is theoretically possible that some library will show you this information.



But I don't really see a way why this might be importatnt for you (in 99.999999% HTTP will use TCP). If you tell us why you are asking this strange question, then perhaps we can answer you more specifically.

+1


source







All Articles