how to send 100 continues in wsgi application ?

G

gert

how do you send 100 continues in a wsgi applications ?

when using curl -T file http://localhost/upload.wsgi on the
wsgiref.simple_server it get stuck waiting for a 100 continue

import os

def application(environ, response):
query=os.path.join(os.path.dirname(__file__),'teeeeeeeeeemp')
range=environ.get('HTTP_CONTENT_RANGE','bytes 0-').replace('bytes
','').split('/')[0].split(',')
offset=[]
for r in range: offset.append(r.split('-'))
with open(query,'ab+') as f:
if environ['REQUEST_METHOD']=='PUT':
f.seek(int(offset[0][0]))
f.truncate()
while True:
chunk=environ['wsgi.input'].read(8192)
if not chunk: break
f.write(chunk)
f.flush()
l=str(os.fstat(f.fileno()).st_size)
response('200 OK', [('Content-Type', 'text/plain'), ('Content-
Length', str(len(l)))])
return [l]
 
D

Dennis Lee Bieber

how do you send 100 continues in a wsgi applications ?

said:
response('200 OK', [('Content-Type', 'text/plain'), ('Content-
Length', str(len(l)))])
return [l]

Probably the same way you send the "200 OK"...

Though that may mean needing to contain session state via a cookie
so the other end can "continue"...

From the protocol definition:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

rfc2616> 10.1 Informational 1xx
rfc2616>
rfc2616> This class of status code indicates a provisional response,
consisting only of the Status-Line and optional headers, and is
terminated by an empty line. There are no required headers for this
class of status code. Since HTTP/1.0 did not define any 1xx status
codes, servers MUST NOT send a 1xx response to an HTTP/1.0 client except
under experimental conditions.
rfc2616>
rfc2616> A client MUST be prepared to accept one or more 1xx status
responses prior to a regular response, even if the client does not
expect a 100 (Continue) status message. Unexpected 1xx status responses
MAY be ignored by a user agent.
rfc2616>
rfc2616> Proxies MUST forward 1xx responses, unless the connection
between the proxy and its client has been closed, or unless the proxy
itself requested the generation of the 1xx response. (For example, if a
rfc2616>
rfc2616> proxy adds a "Expect: 100-continue" field when it forwards a
request, then it need not forward the corresponding 100 (Continue)
response(s).)
rfc2616> 10.1.1 100 Continue
rfc2616>
rfc2616> The client SHOULD continue with its request. This interim
response is used to inform the client that the initial part of the
request has been received and has not yet been rejected by the server.
The client SHOULD continue by sending the remainder of the request or,
if the request has already been completed, ignore this response. The
server MUST send a final response after the request has been completed.
See section 8.2.3 for detailed discussion of the use and handling of
this status code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top