As an extra reference, see the behavior Firefox has when approaching the sample 
server (with some value for the sample field and the Axiom README as the file):

Attachment: ff-behavior.pcap
Description: Binary data

GET / HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) 
Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Cookie: __utma=111872281.1549366989.1321897825.1328517792.1328607177.30; 
__utmz=111872281.1321897825.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

HTTP/1.1 200 OK
Date: Fri, 06 Jul 2012 09:29:11 GMT
Content-Length: 277
Content-Type: text/html
Server: TwistedWeb/12.0.0


        <html>
        <body>
          <form enctype="multipart/form-data" action="/?q=1" method="post">
            <input name="xyzzy">
            <input type="file" name="image">
            <input type="submit">
          </form>
        </body>
        </html>
        POST /?q=1 HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) 
Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Referer: http://localhost:8080/
Cookie: __utma=111872281.1549366989.1321897825.1328517792.1328607177.30; 
__utmz=111872281.1321897825.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Content-Type: multipart/form-data; 
boundary=---------------------------1476689431528312716299916045
Content-Length: 1245

-----------------------------1476689431528312716299916045
Content-Disposition: form-data; name="xyzzy"

123
-----------------------------1476689431528312716299916045
Content-Disposition: form-data; name="image"; filename="README.txt"
Content-Type: text/plain


Divmod Axiom
============

Divmod Axiom is an object database, or alternatively, an object-relational
mapper, implemented on top of Python.

    Note: Axiom currently supports only SQLite and does NOT have any features
    for dealing with concurrency.  We do plan to add some later, and perhaps
    also support other databases in the future.

Its primary goal is to provide an object-oriented layer with what we consider
to be the key aspects of OO, i.e. polymorphism and message dispatch, without
hindering the power of an RDBMS.

Axiom is a live database, not only an SQL generation tool: it includes an
implementation of a scheduler service, external file references, automatic
upgraders, robust failure handling, and Twisted integration.

Axiom is tightly integrated with Twisted, and can store, start, and stop
Twisted services directly from the database using the included 'axiomatic'
command-line tool.


-----------------------------1476689431528312716299916045--
HTTP/1.1 200 OK
Date: Fri, 06 Jul 2012 09:29:45 GMT
Content-Length: 0
Content-Type: text/html
Server: TwistedWeb/12.0.0

cheers
lvh



On 06 Jul 2012, at 10:47, Laurens Van Houtven wrote:

> Hi,
> 
> I have some code that takes file uploads from browsers. I'm trying to write a 
> test for it, so now I need to get Twisted to do file uploads like browsers 
> do. I think my code (not test code) essentially works, by manually trying it 
> with a browser. I can't get the functional test part to work.
> 
> I have reduced the problem to what I think is a SSCCE. render_POST drops into 
> a debugger to easily inspect the received request.
> 
> Here's the code: https://gist.github.com/3058974
> 
> When debugging this with wireshark I found an obvious culprit: there's some 
> random junk in front of it (3 ASCII hex digits and a CRLF) and some junk at 
> the end (CRLF and an ASCII "0", although I'm not sure if that CRLF is junk). 
> Wireshark reports some broken TCP packets (PCAP attached). I have no idea why 
> that happens. Packets were captured with:
> 
>    tcpdump -i lo0 -nn -s0 -w sample.pcap port 8080
> 
> and analyzed with a recent version of Wireshark (1.6.2, SVN rev 38931). The 
> analyzed TCP stream is also attached.
> 
> <tcpdata.txt><test.pcap>
> 
> If I look at the request in the debugger (request_POST *DOES* get called…):
> 
> - it has an empty request.args, instead of having the expected keys "a", "b", 
> "f"
> - request.content.getvalue() has the data you see in tcpdata.txt: it starts 
> with "'1e7\r\n------------" even though I obviously would like it to start 
> with just the dashes
> 
> cheers
> lvh
> 
> 
> 

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to