views:

82

answers:

0

The problem is that my servlet doesn't fetch the parameter "protocolversion" (see below) for my Python script for some odd reason. The getParameter call always returns null! Is perhaps the HTTP post request invalid? I use Tomcat 6 with default configuration. A strange thing I've noticed when logging with Wireshark is that Tomcat responds with a HTTP/1.1 response. The default connector should fall back to HTTP/1.0 in this case as far as I understand, shouldn't it? Any ideas on what might be wrong?

Java servlet code snippet:

protected void doPost(HttpServletRequest request, 
                      HttpServletResponse response) 
    throws ServletException, 
           IOException
{
    String pv = request.getParameter("protocolversion");
}

Python test client script:

import socket

host = 'localhost'
port = 8084

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))

new_line = '\r\n'

data = 'POST /DemoServlet HTTP/1.0' + new_line + \
       'connection: close' + new_line + \
       'content-length: 17' + new_line + \
       'host: ' + host + new_line + \
        new_line + \
       'protocolversion=1'

s.send(data)
print data
print '---'
print s.recv(256) + s.recv(256)
s.close()