<hack_web2py.png>
<hack_web2py.png>
can you try this new main.py and see if it does what you ask?
On Apr 25, 2008, at 8:19 AM, ygao wrote:
On Apr 26, 2008, at 6:03 AM, ygao wrote:
> --_000_a90eeef0804260403x3116a36axd4efd7edf7cb7337mailgmailcom_
> Content-Type: text/plain; charset="utf-8"
> Content-Transfer-Encoding: base64
>
> DQoNCk9uIFNhdCwgQXByIDI2LCAyMDA4IGF0IDEyOjEwIEFNLCBNYXNzaW1vIERpIFBpZX
> JybyA8
> bWRpcGllcnJvQGNzLmRlcGF1bC5lZHU8bWFpbHRvOm1kaXBpZXJyb0Bjcy5kZXBhdWwuZW
> R1Pj4g
> d3JvdGU6DQpjYW4geW91IHRyeSB0aGlzIG5ldyBtYWluLnB5IGFuZCBzZWUgaWYgaXQgZG
> 9lcyB3
> aGF0IHlvdSBhc2s/
> DQoNCml0IGRvZXMsZ3JlYXQhIEkga25vdyBhIGZldyBhYm91dCBIVFRQIDIw
> Ni4NCmlmIHRoZSBmaWxlIHNpemUgaXMgeHggZ2IsSSB0aGluayB5b3VyIGhhdmUgYSBwcm
> 9ibGVt
> LnRoZSBwcm9ibGVtIGlzIGxvYWRpbmcgYWxsIGNvbnRlbnQgaW50byBtZW1vcnkuDQpJIH
> VzZSBo
> YWNrZWQgcmVxdWVzdCB0byBkbyBzb21ldGhpbmcgbGlrZSB0aGlzOnlvdSBzZWUgdGhpcy
> BpcyB2
> ZXJ5IHNpbXBsZSBhbmQgcG93ZXJmdWwuIHlvdSBjYW4gdXNlIGFueSB3ZWJvYiBNaWRkbG
> V3YXJl
> Lg0Kc28gZG9uJ3QgcmUtaW52ZW50IHdoZWVsLg0KICAgICAgICAgICAgICAgICAgICBpZi
> AgcmVx
> dWVzdC5yYW5nZToNCiAgICAgICAgICAgICAgICAgICAgICAgIGFwcCA9IEZpbGVBcHAoc3
> RhdGlj
> X2ZpbGUpDQogICAgICAgICAgICAgICAgICAgICAgICByZXMgPSByZXF1ZXN0LmdldF9yZX
> Nwb25z
>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vigLvigLvigLvigLsNCmh0dHA6Ly9CTE9HLmRvbm
> V3cy5j
> b20veWdhbw0KVWxpUGFkOlRoZSBwb3dlcmZ1bCBQeXRob24gZWRpdG9yDQpVbGlQYWQ6VG
> hlIHBv
> d2VyZnVsIFB5dGhvbiBlZGl0b3INCi0tfi0tfi0tLS0tLS0tLX4tLX4tLS0tfi0tLS0tLS
> 0tLS0t
> LX4tLS0tLS0tfi0tfi0tLS1
> +DQpZb3UgcmVjZWl2ZWQgdGhpcyBtZXNzYWdlIGJlY2F1c2UgeW91
> IGFyZSBzdWJzY3JpYmVkIHRvIHRoZSBHb29nbGUgR3JvdXBzICJ3ZWIycHkgV2ViIEZyYW
> 1ld29y
> ayIgZ3JvdXAuDQpUbyBwb3N0IHRvIHRoaXMgZ3JvdXAsIHNlbmQgZW1haWwgdG8gd2ViMn
> B5QGdv
> b2dsZWdyb3Vwcy5jb20NClRvIHVuc3Vic2NyaWJlIGZyb20gdGhpcyBncm91cCwgc2VuZC
> BlbWFp
> bCB0byB3ZWIycHktdW5zdWJzY3JpY
I am not sure I opened you email correctly. Could you explain me
again what you are proposing.
Could you also tell me how do you test 206?
Massimo
You can also use this to serve static files not stored in
'static' (for example uploaded files) in your own controllers by calling
response.stream(filename,request=request)
form the request determines if IF_MODIFIED_SINCE is in the headers
and if file has not been modified returns 304
also from the request, if RANGE is in the headers, it streams only
the request portion of the file.
It also sets automatically the content_length, content-range, content-
type headers.
No need to say the old syntax
return response.stream(open(filename,'rb'))
works and it is still supported for backward compatibility.
Please check it before we make this official.
Massimo
I posted another version in trunk 191.
As before it now streams all static content but also properly serves
partial files using 206 PARTIAL CONTENT.
This is transparent to the user. There is nothing you need to do.
You can also use this to serve static files not stored in
'static' (for example uploaded files) in your own controllers by calling
response.stream(filename,request=request)
form the request determines if IF_MODIFIED_SINCE is in the headers
and if file has not been modified returns 304
also from the request, if RANGE is in the headers, it streams only
the request portion of the file.
It also sets automatically the content_length, content-range, content-
type headers.
No need to say the old syntax
return response.stream(open(filename,'rb'))
works and it is still supported for backward compatibility.
Please check it before we make this official.
Massimo
On Apr 26, 2008, at 10:19 AM, Massimo Di Pierro wrote:
>
> I am not sure I understand your suggestion. Currently web2py already
> does streaming in both upload and download of large files. Streaming
> works also for the 206 PARTIAL CONTENT. It is done by the code in
> gluon/streamer.py
>
> I am not sure I opened you email correctly. Could you explain me
> again what you are proposing.
>
> Could you also tell me how do you test 206?
>
> Massimo
>
> >
I am not sure I understand your suggestion. Currently web2py already
does streaming in both upload and download of large files. Streaming
works also for the 206 PARTIAL CONTENT. It is done by the code in
gluon/streamer.py
I am not sure I opened you email correctly. Could you explain me
again what you are proposing.
Could you also tell me how do you test 206?
Massimo