Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Dirkjan Ochtman
On Thu, Sep 16, 2010 at 21:39, P.J. Eby p...@telecommunity.com wrote:
 Or, to put it another way: splitting the spec into two 100% incompatible
 versions is a bad idea for Python 3 adoption.  With a WSGI 1 addendum, we
 should be able to make it possible to put the same apps and middleware on 2
 and 3 with just a decorator wrapping them.  (i.e., people should be able to
 write libraries that run on both 2 and 3, which is probably critical to
 adoption).

 I just wish I'd come to these conclusions much sooner...  like a year or two
 ago.  :-(

Meh, I'd much rather have Web3/WSGI 2 (and I prefer the WSGI name,
too) for Python 3 than the small update you're proposing. IMO there
are some good improvements in Chris  Armin's spec over the original
WSGI, and I would be sad to have to go back to an incremental update
that does just enough to make PEP 333 work on Python 3. (Also I think
there might actually be value in having some incompatibility to make
the distinction clearer.)

Cheers,

Dirkjan
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Georg Brandl
Am 16.09.2010 20:00, schrieb Ian Bicking:
 On Thu, Sep 16, 2010 at 12:35 PM, Guido van Rossum
 gu...@python.org
 mailto:gu...@python.org wrote:
 
 On Thu, Sep 16, 2010 at 10:01 AM, Ian Bicking
 i...@colorstudy.com
 mailto:i...@colorstudy.com wrote:
  Well, reiterating some things I've said before:
 
  * This is clearly just WSGI slightly reworked, why the new name?
  * Why byte values in the environ?  No one has offered any real reason 
 they
  are better than native strings.  I keep asking people to offer a reason,
  *and no one ever does*.  It's just hyperbole and distraction.  Frankly 
 I'm
  feeling annoyed.  So far my experience makes me believe using native 
 strings
  will make it easier to port and support libraries across 2 and 3.
 
 Hm. IIUC the proposal is to implicitly assume Latin1 when decoding the
 bytes to Unicode. I worry that this will just perpetuate mojibake and
 other atrocities committed in Python 2.
 
 
 I was reading http://python.org/dev/peps/pep-0444/ -- is there another 
 revision
 under discussion?  This seems to explicitly say all environ values will be
 bytes.  There have been other str-oriented proposals, including mod_wsgi's
 implementation.

IIUC Guido was referring to your proposal.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.

___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Benoit Chesneau
On Fri, Sep 17, 2010 at 10:36 AM, Georg Brandl g.bra...@gmx.net wrote:
 Am 16.09.2010 23:07, schrieb James Mills:
 - the web3 name

  If there is any value in this PEP and we find something to decide on,
  there is no reason this couldn't be WSGI 2.  But until it's just
  something a small part of the web-sig community worked on directly
  a separate name is a good thing I think, because it does not reserve
  the name WSGI 2 for something that might actually become WSGI 2
  in case this PEP gets rejected.

 I personally still don't see any real benefit to changing the key names
 from wsgi to web3 (or whatever). I would prefer it remain the
 same. If you're going to use Python3, you know you're using Python3
 (you don't need web3 key names to know that). (subjective)

 That statement shows another weakness of the web3 name: this spec is not
 in the least exclusive to Python 3.  (Which would be a bit useless, having
 two incompatible WSGI/web specs on two incompatible Python versions.)

 The goal would be to first migrate to WSGI2/web3, and *then* have an easy
 transition going to Python 3.

 Georg

also WSGI acronym is defining better the purpose by itself than web3
which mean nothing.

- benoit
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Benoit Chesneau
On Thu, Sep 16, 2010 at 6:41 PM, Armin Ronacher
armin.ronac...@active-4.com wrote:

  4. The web3 spec says, In case a content length header is absent the
     stream must not return anything on read. It must never request more
     data than specified from the client. but later it says, Web3
     servers must handle any supported inbound hop-by-hop headers on
     their own, such as by decoding any inbound Transfer-Encoding,
     including chunked encoding if applicable.. I would be sad if web3
     did not support streaming uploads via Transfer-Encoding. One way to
     implement that would be to make the origin server handle read()
     transparently by returning '' on EOF, regardless of whether a
     Content-Length or a Transfer-Encoding header was provided.

 I was toying with the idea to have a websocket extension for web3 which
 would have solved my usecase for requests without a content-length header.
  The problem with the content length of incoming data is quite complex and
 that seemed to be the solution that was easiest for everybody involved.

uh ? Since with Transfer-Encoding: chunked we know when the stream
end, I would be in favor of returning an EOF too at the end. Also most
of servers know when a stream end even if there is no content-length.
Maybe we could have a capability setting in environ that say if the
server support streaming or not. And in all cases returning EOF at the
end?

- benoît
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread And Clover

On 09/17/2010 04:21 AM, Ian Bicking wrote:


Yes, if we get rid of SCRIPT_NAME/PATH_INFO then the problem goes away.  For
servers without access to the unencoded value, reencoding those values
doesn't actually lose any information over what we have now, and avoids any
encoding issues.


It doesn't lose any information, but it also makes script_name/path_info 
inherently unreliable. My fear is that if gateways are allowed to create 
a reconstructed script_name/path_info without clearly signalling they 
have done so, those values will continue to be unreliable at all times 
and server authors won't feel the need to get it right since it's broken 
everywhere anyway: the unhappy status quo.


This is why I am continuing to plead for a 'script_name/path_info are 
authoritative' flag in environ that applications can use to detect 
situations where it is safe to go ahead and rely on them. I want to say 
Unicode paths are supported if your server/gateway does, not Unicode 
paths might sometimes work, depending on how you configure your server 
and application.


It is not just CGI that is affected here! IIS does not provide the 
original undecoded path at all, even through ISAPI.


At the moment I am using a 'fixPathInfo' method in my form-reading layer 
to try to compensate as much as possible for the problems of CGI:


  - on Python 2 on Windows, re-read the environment variables using
ctypes if available, to avoid the mangling caused by reading
os.environ using mbcs. (This didn't used to work, as old versions
of IIS deliberately mbcs-filtered values before putting them in the
environment, but it does now.)

  - on Python 3 on POSIX, re-read the environment variables using
environb if available. Otherwise try to reverse the faulty decoding
of environ using surrogateescapes, where available.

  - on Windows, encode the Unicode environment to bytes using
ISO-8859-1 if the server is Apache, or UTF-8 is the server is
IIS. (IIS tries to decode path bytes using UTF-8, falling back
to mbcs where the input is not valid UTF-8. Unfortunately there
is no way to tell this has happened.)

  - when server is Microsoft-IIS, remove the erroneously repeated
SCRIPT_NAME components from the front of PATH_INFO. (This is a
long-standing bug that can be configured away using the
allowPathInfo/AllowPathInfoForScriptMappings configs, but no-
one does as it breaks ASP.)

However, the form layer is not really the right place to be doing these 
hacks. It would be better done in the stdlib CGI handler.



Servers with REQUEST_URI can at least attempt to
reconstruct the encoded values.


This is slightly unsafe. It's something an application might want to do 
(or at least provide as an option), but a gateway probably couldn't get 
away with it for the general case because REQUEST_URI doesn't reflect 
the redirections done by a RewriteRule or an ErrorDocument.



Cookie is also the one header that can't be safely folded.


There are others, eg. Authorization. Anyway: folding doesn't happen in 
the HTTP world. It can be forgotten about.


--
And Clover
mailto:a...@doxdesk.com
http://www.doxdesk.com/
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Armin Ronacher

Hi,

On 9/17/10 11:40 AM, And Clover wrote:

This is why I am continuing to plead for a 'script_name/path_info are
authoritative' flag in environ that applications can use to detect
situations where it is safe to go ahead and rely on them. I want to say
Unicode paths are supported if your server/gateway does, not Unicode
paths might sometimes work, depending on how you configure your server
and application.
In case there is no raw value with the current spec, you can see 
SCRIPT_NAME and PATH_INFO as unreliable.  In case we change the spec as 
Ian mentioned above, I am all for a wsgi.guessed_encoding = True flag 
or something like that.



It is not just CGI that is affected here! IIS does not provide the
original undecoded path at all, even through ISAPI.
Unless I am mistaken, the same is true for CGI scripts running on 
Apache2 on Windows.



- on Python 2 on Windows, re-read the environment variables using
ctypes if available, to avoid the mangling caused by reading
os.environ using mbcs. (This didn't used to work, as old versions
of IIS deliberately mbcs-filtered values before putting them in the
environment, but it does now.)
I did some tests a while ago and was pretty sure that Apache2 on Windows 
did the same.  Might be wrong though.



However, the form layer is not really the right place to be doing these
hacks. It would be better done in the stdlib CGI handler.
The correct place for these hacks would be the appropriate WSGI/Web3 
handler of the webserver.  Certainly not a particular WSGI/Web3 
implementation or even the CGI module of the standard library.



Regards,
Armin
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread And Clover

On 09/17/2010 02:03 PM, Armin Ronacher wrote:


In case we change the spec as Ian mentioned above, I am all for
a wsgi.guessed_encoding = True flag or something like that.


Yes, I'd like to see that. I believe going with *only* a 
raw-or-reconstructed path_info, rather than having both path_info and 
PATH_INFO, is probably best, for the middleware-dupication reasons PJE 
mentioned.


A more in-depth possibility might be:

wsgi.path_accuracy =

0: script_name/path_info have been crudely reconstructed from
SCRIPT_NAME/PATH_INFO from an unknown source. Beware!
If there is to be backwards compatibility with WSGI1, this
would be seen as the 'default value' given a missing path_accuracy.

1: script_name/path_info have been reconstructed, but it is known
that path_info is accurate, other than %2F and non-ASCII issues.
That is, it's known that the path doesn't come from IIS's broken
PATH_INFO, or the IIS error has been detected and compensated for.

2: script_name/path_info have been reconstructed using known-good
encodings for the env. The only way in which they may differ from
the original request path is that a slash might originally have
been a %2F. (This is good enough for the vast majority of
applications.)

3: script_name/path_info come directly from the request path
without any intervening mangling.


Unless I am mistaken, the same is true for CGI scripts running on
Apache2 on Windows.


Yes, it's true of *all* CGI scripts, but also for non-CGI scripts on IIS.


I did some tests a while ago and was pretty sure that Apache2 on Windows
did the same.


Apache-on-Windows puts the bytes of the decoded path into the 
environment variables as one code unit per byte: that is, as if encoded 
by ISO-8859-1. You still have to read the environ using ctypes because 
mbcs is never ISO-8859-1, but at least the original bytes are 
recoverable, which isn't the case with IIS.



The correct place for these hacks would be the appropriate WSGI/Web3
handler of the webserver.


The IIS PATH_INFO-prefix hack would be appropriate to put in an 
IIS-specific handler; indeed, I believe isapi_wsgi does just that. But 
the other hacks are specific to CGI.


For CGI, there is no 'handler of the webserver', there is only the 
standard CGI-to-WSGI adapter, so this is the only component it is 
reasonable to burden with the hacks. Frameworks and libraries further up 
the stack cannot reliably do the fixups, because they don't know whether 
the WSGI environ they have been given comes from os.environ or somewhere 
else, or whether middleware has played with it.


--
And Clover
mailto:a...@doxdesk.com
http://www.doxdesk.com/
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread P.J. Eby

At 03:43 PM 9/17/2010 +0200, And Clover wrote:

On 09/17/2010 02:03 PM, Armin Ronacher wrote:


In case we change the spec as Ian mentioned above, I am all for
a wsgi.guessed_encoding = True flag or something like that.


Yes, I'd like to see that. I believe going with *only* a 
raw-or-reconstructed path_info, rather than having both path_info 
and PATH_INFO, is probably best, for the middleware-dupication 
reasons PJE mentioned.


A more in-depth possibility might be:

wsgi.path_accuracy =

0: script_name/path_info have been crudely reconstructed from
SCRIPT_NAME/PATH_INFO from an unknown source. Beware!
If there is to be backwards compatibility with WSGI1, this
would be seen as the 'default value' given a missing path_accuracy.

1: script_name/path_info have been reconstructed, but it is known
that path_info is accurate, other than %2F and non-ASCII issues.
That is, it's known that the path doesn't come from IIS's broken
PATH_INFO, or the IIS error has been detected and compensated for.

2: script_name/path_info have been reconstructed using known-good
encodings for the env. The only way in which they may differ from
the original request path is that a slash might originally have
been a %2F. (This is good enough for the vast majority of
applications.)

3: script_name/path_info come directly from the request path
without any intervening mangling.


So, do you have an example of what some real-world code is going to 
*do* with this information?  i.e., what's the use case for knowing 
the precise degree of messed-uppedness of the path?  ;-)


___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Armin Ronacher

Hi,

On 9/17/10 5:42 PM, P.J. Eby wrote:

So, do you have an example of what some real-world code is going to *do*
with this information? i.e., what's the use case for knowing the precise
degree of messed-uppedness of the path? ;-)
Actually, I can see a couple of use cases.  I have a blog that by 
default only produces ASCII-safe slugs for the URLs which means that if 
you are a chinese person you will only get the ID based fallback there. 
 If I could safely detect if the setup supports unicode identifiers in 
URLs in a way that works, I could give a good default and warn the user 
if they change the setting.



Regards,
Armin
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Ionel Maries Cristian
I don't like this proposal at all. Besides having to go through the bytes
craziness the design is pretty backwards for middleware and asynchronous
applications.

Even the proxy_and_timing_support example in the PEP is broken for async or
streaming apps - it won't return the proper time (since it doesn't consume
the body iterable) and it will fail most of the times since you can't just
add a tuple to a iterable.

The missing requirement that middleware must yield at least an empty string
if they need more more information from the application iterable also breaks
async gateways that expect oob information from the app (for example cogen
can't be ported to this spec).

The removed requirement middleware components *must not* block iteration
waiting for multiple values from an application iterable. If the middleware
needs to accumulate more data from the application before it can produce any
output, it *must* yield an empty string. also breaks async gateways/apps.

I feel this spec puts too much burden on applications - having to process
all those byte strings and even having to add Content-Length even for naive
buffered-body apps.

--ionel



On Thu, Sep 16, 2010 at 02:03, Chris McDonough chr...@plope.com wrote:

 A PEP was submitted and accepted today for a WSGI successor protocol
 named Web3:

 http://python.org/dev/peps/pep-0444/

 I'd encourage other folks to suggest improvements to that spec or to
 submit a competing spec, so we can get WSGI-on-Python3 settled soon.

 - C


 ___
 Web-SIG mailing list
 Web-SIG@python.org
 Web SIG: http://www.python.org/sigs/web-sig
 Unsubscribe:
 http://mail.python.org/mailman/options/web-sig/ionel.mc%40gmail.com

___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Chris McDonough
On Fri, 2010-09-17 at 19:47 +0300, Ionel Maries Cristian wrote:
 I don't like this proposal at all. Besides having to go through the
 bytes craziness the design is pretty backwards for middleware and
 asynchronous applications.

We've acknowledged in other messages to this thread that the web3.async
red herring is speculative, and Armin has indicated that if he does not
find a champion willing to create a reference implementation for it
today that it will be taken out.  This doesn't help async people, but it
also doesn't harm them (no difference from WSGI really).  Personally, I
hope nobody steps up and we just rip it out. ;-)

I'm not sure why you characterize using bytes as bytes craziness.  We
have been using strings as byte sequences in WSGI for over five years.
Python itself draws an equivalence between the Python 3 bytes type and
Python 2 str (bytes is aliased to str under Python 2).  I'm not
really sure why we shouldn't take advantage of that equivalence, and why
people are so enamored of treating envvar values, headers, and such as
text other than the brokenness of the Python 3 stdlib urllib stuff.  

IMO, WSGI/Web3 isn't really a programming platform (or at least if it
is, it is destined to be a pretty crappy one), it's just a connection
protocol, so any its more typing or its ugly argument seems pretty
thin to me.  I'd personally rather have it be more general and less easy
to use than potentially broken in some corner case circumstance.

- C


___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Ian Bicking
On Fri, Sep 17, 2010 at 9:43 AM, And Clover and...@doxdesk.com wrote:

 On 09/17/2010 02:03 PM, Armin Ronacher wrote:

  In case we change the spec as Ian mentioned above, I am all for
 a wsgi.guessed_encoding = True flag or something like that.


 Yes, I'd like to see that. I believe going with *only* a
 raw-or-reconstructed path_info, rather than having both path_info and
 PATH_INFO, is probably best, for the middleware-dupication reasons PJE
 mentioned.

 A more in-depth possibility might be:

 wsgi.path_accuracy =

0: script_name/path_info have been crudely reconstructed from
SCRIPT_NAME/PATH_INFO from an unknown source. Beware!
If there is to be backwards compatibility with WSGI1, this
would be seen as the 'default value' given a missing path_accuracy.

1: script_name/path_info have been reconstructed, but it is known
that path_info is accurate, other than %2F and non-ASCII issues.
That is, it's known that the path doesn't come from IIS's broken
PATH_INFO, or the IIS error has been detected and compensated for.

2: script_name/path_info have been reconstructed using known-good
encodings for the env. The only way in which they may differ from
the original request path is that a slash might originally have
been a %2F. (This is good enough for the vast majority of
applications.)

3: script_name/path_info come directly from the request path
without any intervening mangling.


path_accuracy is certainly a better name than encoding; nothing here
actually relates to encoding (except insofar as attempts to encode or
reencode values corrupts the path).  Personally I wouldn't want to split it
up this much, I'd rather a simple flag to indicate something was guessed,
vs. an accurate request.  The only real value I see in it is to help people
debug problems.  Maybe.  I'm not sure it's that realistic to imagine this
will be noticed by people deploying software and encountering problems.  A
helpful application could use it to warn the deployer of potential problems.

It seems that it would be possible to create a WSGI application and client
library that together can detect and help resolve these issues.  E.g., the
application always returns the values of script_name, path_info, and
query_string, and the client fires off a bunch of different requests to see
how it gets interpreted.  It could suggest corrections until everything
passes.

I would really like to see concerns over bad gateways not be used to keep
valuable information out of the spec.  We want people to use well-configured
gateways that accurately represent requests.  There are limits, e.g., in
environments where information is lost.  The only really problematic example
is losing the distinction between %2f and /, and I think it's reasonable to
suggest that applications should avoid making that distinction in the path
if they want to be easily deployed in different environments.


-- 
Ian Bicking  |  http://blog.ianbicking.org
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Ian Bicking
On Fri, Sep 17, 2010 at 1:02 PM, Ian Bicking i...@colorstudy.com wrote:

 I would really like to see concerns over bad gateways not be used to keep
 valuable information out of the spec.  We want people to use well-configured
 gateways that accurately represent requests.  There are limits, e.g., in
 environments where information is lost.  The only really problematic example
 is losing the distinction between %2f and /, and I think it's reasonable to
 suggest that applications should avoid making that distinction in the path
 if they want to be easily deployed in different environments.


Just to expand -- the reason %2f is special is because / has special meaning
in URL paths, or at least is treated as such.  ? has special meaning too,
but that's already handled by splitting off QUERY_STRING.  Technically ; is
supposed to mean something, but no one ever cared, so it doesn't really.  In
theory you could make any character special, and in doing so want an escape
mechanism to determine the difference between, e.g., , and %2c... but no
one does that, so no problem.

All the other potential problems are problems of gateway corruption.  E.g.,
where the bytes were decoded with Latin1 and then encoded with
sys.getfilesystemencoding(), or some other mismatched combination.  I don't
believe we should expose gateway corruption to the spec.  I *do* believe
that we can build tools inside WSGI to help debug and fix those problems,
and I don't think any of these changes makes those tools particularly harder
to implement.

-- 
Ian Bicking  |  http://blog.ianbicking.org
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread chris . dent

On Fri, 17 Sep 2010, Ionel Maries Cristian wrote:


I feel this spec puts too much burden on applications - having to process
all those byte strings and even having to add Content-Length even for naive
buffered-body apps.


The Content-Length requirement is a big killer for me. I'm usually
generating content in apps, rather deep in a stack of middleware-like
pieces that may or may not be looking at or modifying that content.
I don't want to a) have to unwind my generators at each level b)
reset the content-length here there and everywhere.

It could be I'm doing it completely wrong, but it works rather
nicely.

--
Chris Dent   http://burningchrome.com/
[...]
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Ian Bicking
On Fri, Sep 17, 2010 at 1:37 PM, chris.d...@gmail.com wrote:

 On Fri, 17 Sep 2010, Ionel Maries Cristian wrote:

  I feel this spec puts too much burden on applications - having to process
 all those byte strings and even having to add Content-Length even for
 naive
 buffered-body apps.


 The Content-Length requirement is a big killer for me. I'm usually
 generating content in apps, rather deep in a stack of middleware-like
 pieces that may or may not be looking at or modifying that content.
 I don't want to a) have to unwind my generators at each level b)
 reset the content-length here there and everywhere.

 It could be I'm doing it completely wrong, but it works rather
 nicely.


I'm unclear what exactly you guys are reacting to.  This?


   - The server must not inject an additional Content-Length header by
   guessing the length from the response iterable. This must be set by the
   application itself in all situations.


I'm also not sure what motivated this particular change, but I don't have
any opinion one way or the other.

-- 
Ian Bicking  |  http://blog.ianbicking.org
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Armin Ronacher

Hi,

On 9/17/10 7:43 PM, Ian Bicking wrote:

I'm also not sure what motivated this particular change, but I don't
have any opinion one way or the other.

Motivation is that WSGI wants servers to do something like this:

   if len(iterable) == 1 and content_length_header_missing:
   headers.append(('Content-Length', str(len(iterable[0])))

However not everybody was doing that and some applications were setting 
a content length header or not.  If a content length header was not set 
some middlewares that changed content worked properly even though they 
did not check the header.  The idea is that with web3 every tool in the 
chain is supposed to look for that header and update it appropriately.


Even the piglatin middleware from the PEP 333 did not check the content 
length if I remember correctly.



Regards,
Armin
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] PEP 444 (aka Web3)

2010-09-17 Thread Ian Bicking
On Fri, Sep 17, 2010 at 2:06 PM, Armin Ronacher armin.ronac...@active-4.com
 wrote:

 Hi,


 On 9/17/10 7:43 PM, Ian Bicking wrote:

 I'm also not sure what motivated this particular change, but I don't
 have any opinion one way or the other.

 Motivation is that WSGI wants servers to do something like this:

   if len(iterable) == 1 and content_length_header_missing:
   headers.append(('Content-Length', str(len(iterable[0])))

 However not everybody was doing that and some applications were setting a
 content length header or not.  If a content length header was not set some
 middlewares that changed content worked properly even though they did not
 check the header.  The idea is that with web3 every tool in the chain is
 supposed to look for that header and update it appropriately.

 Even the piglatin middleware from the PEP 333 did not check the content
 length if I remember correctly.


OK, so maybe it should just be clarified:

* Middleware and servers should not modify or add Content-Length, Date, or
other headers unless they have reason to do so, and they must ensure that
the response is valid (e.g., there should never be two Content-Length
headers).

It still seems reasonable that *if* there is no Content-Length, and the
server can guess easily enough (mostly it is returned an actual list/tuple
that we know can be introspected fast and without side effects), then it's
perfectly reasonable to set it -- but certainly the server doesn't own
that header (or any other, except maybe some connection-related headers?).

-- 
Ian Bicking  |  http://blog.ianbicking.org
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com