views:

33

answers:

0

I have a form that is multi-part for file upload, but it also has some other parameters like username, password, etc.

Here's what the HTML form looks like: http://pastebin.com/AjmGsQBu

And here's my python code to handle it: http://pastebin.com/kj1PBYmH

I've verified with Charles that all the parameters are being submitted, they're just not available on the fapws side.

This is what the print(environ) spits out:

{'fapws.params': {}, 'HTTP_PRAGMA': 'no-cache', 'HTTP_CONTENT_LENGTH': '2069363', 'HTTP_REFERER': 'http://localhost:9001/tag/create', 'CONTENT_TYPE': 'multipart/form-data; boundary=----WebKitFormBoundaryGI4fKoTXGI00dtBx', 'fapws.uri': '/tag/create/', 'SCRIPT_NAME': '/tag/create', 'wsgi.input': , 'REQUEST_METHOD': 'POST', 'HTTP_HOST': 'localhost:9001', 'PATH_INFO': '/', 'HTTP_ORIGIN': 'http://localhost:9001/', 'wsgi.multithread': False, 'QUERY_STRING': '', 'HTTP_CONNECTION': 'close', 'HTTP_CONTENT_TYPE': 'multipart/form-data; boundary=----WebKitFormBoundaryGI4fKoTXGI00dtBx', 'HTTP_X_REAL_IP': '127.0.0.1', 'HTTP_X_SCHEME': 'http', 'fapws.remote_port': 50011, 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/534.1+ (KHTML, like Gecko) Version/5.0 Safari/533.16', 'wsgi.version': (1, 0), 'fapws.major_minor': '1.0', 'SERVER_NAME': '0.0.0.0', 'REMOTE_ADDR': '127.0.0.1', 'wsgi.run_once': False, 'wsgi.errors': , 'wsgi.multiprocess': True, 'HTTP_ACCEPT_LANGUAGE': 'en-us', 'HTTP_PROTOCOL': 'HTTP/1.0', 'fapws.protocol': 'HTTP', 'wsgi.url_scheme': 'http', 'fapws.remote_addr': '127.0.0.1', 'SERVER_PORT': 'POST', 'CONTENT_LENGTH': 2069363, 'HTTP_ACCEPT': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate'}

I was snooping around and noticed environ["wsgi.input"] is the raw input for the request.

Does anyone know if there are any helpers in FAPWS to parse this?

Optionally I've looked at pythons cgi module because it looks like it has some useful helpers, but haven't been able to get it to correctly parse the raw input.