Is there a way in Java to know if an HTTP request was received over TCP or over UDP?
2 Answers
Quote from the RFC2616
HTTP communication usually takes place over TCP/IP connections. The default port is TCP 80 [19], but other ports can be used. This does not preclude HTTP from being implemented on top of any other protocol on the Internet, or on other networks. HTTP only presumes a reliable transport; any protocol that provides such guarantees can be used; the mapping of the HTTP/1.1 request and response structures onto the transport data units of the protocol in question is outside the scope of this specification.
I would say this eliminates default UDP. Other Reliable forms of protocols would still be possible
Comments
As @ceekay says, RFC tells that HTTP uses reliable transport only, so that means no way for UDP. But one may try to build some other protocol on top of UDP, or may be do not use TCP/IP stack at all.. But as your question is about Java, then the answer is - this is all about Java libraries and frameworks used. Actually all the libraries that I know, like HtmlUnit http://htmlunit.sourceforge.net for example, hide this information from you. So you are dealing with HTTP(s) only without knowing details about underground transport. But in theory this is possible that some library will show this information for you.
But actually I do not see a way why this may be importatnt for you (in 99.999999% HTTP will use TCP). If you tell us why you are asking that strange question, then maybe we will answer you more specific.
HTTPinformationhttpusually does not run overudp, but it does not mean it's not possible. And I was thinking that this could be a security issue. So I was wandering if it's even possible...