I want to use
LocalConnector.getResponses( "POST /myservlet/SpecialRequest HTTP/1.0\r\nContent-Length: x\r\n\r\n<content>\r\n\r\n" );
to send special requests to servlets from within my application (uses embedded Jetty server). How can the Servlet detect that the request isfrom a LocalConnector instead of an external source?
The doPost method only has a HttpServletRequest and HttpServletResponse objects as parameters.
Using Jetty 9.2.4 and Servlet 3.1 APIs.
I determined there is no way to identify the Connector but looking inside the request, there are a few 0.0.0.0 and port 0 values which I'm confident wouldn't be the case from any external request (even localhost requests show up as 127.0.0.1).
LocalAddr = 0.0.0.0
LocalName = 0.0.0.0
LocalPort = 0
ServerName = <a real ip>
ServerPort = 80
RemoteAddr = 0.0.0.0
RemoteHost = 0.0.0.0
The ServerName and ServerPort are bogus - I don't have a Connector on port 80 and the request log shows
0.0.0.0 - - [21/Nov/2014:11:20:56 -0500] "POST /myservlet/SpecialRequest HTTP/1.0" - 0 "-" "-" "-"
which doesn't match the ServerName.
Conclusion: if LocalAddr and RemoteAddr are 0.0.0.0, request is internal from the LocalConnector.
Hope this answer helps the next person - and thanks to the one who posted the other LocalConnector question which pointed me to that feature!