Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'broken': 0.03; 'subject:Python': 0.05; 'case.': 0.05; 'discard': 0.05; 'reason,': 0.07; 'blocking': 0.09; 'exceeds': 0.09; 'length.': 0.09; "wouldn't": 0.11; '(the': 0.15; 'deadlock': 0.16; 'eckhardt': 0.16; 'length,': 0.16; 'line)': 0.16; 'project)': 0.16; 'shutdown()': 0.16; 'twisted': 0.16; 'subject:Issue': 0.17; 'jan': 0.18; 'http': 0.22; 'work,': 0.22; 'work.': 0.23; 'errors': 0.23; 'header:In-Reply-To:1': 0.25; '----------': 0.26; 'wondering': 0.26; 'question': 0.27; '+0100': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'skip:( 20': 0.28; 'subject:list': 0.28; 'header,': 0.29; 'request,': 0.29; 'date:': 0.29; 'case,': 0.29; "i'm": 0.29; 'connection': 0.30; 'server.': 0.32; 'file': 0.32; 'could': 0.32; 'skip:s 30': 0.33; 'advertised': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; "can't": 0.34; 'received:google.com': 0.34; 'server': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'subject:': 0.36; 'but': 0.36; 'closing': 0.36; 'data.': 0.36; 'email addr:python.org': 0.36; 'client': 0.36; 'should': 0.36; 'does': 0.37; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'comment': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'subject:-': 0.40; 'your': 0.60; 'subject:, ': 0.61; 'personally': 0.61; 'side': 0.61; 'back': 0.62; 'email name:python-list': 0.62; 'close': 0.63; 'request.': 0.64; 'sit': 0.65; 'finally': 0.66; 'fact,': 0.69; 'receive': 0.71; 'connection.': 0.75; 'charset:gb2312': 0.77; '2013': 0.84; 'closing,': 0.84; 'couch': 0.84; 'here...': 0.84; 'interrupt': 0.84; 'nice,': 0.84; 'approach.': 0.91; 'do:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=7hxI49D2Q3L1v29VNR4ACL/vb3fyyuQIMZiWI4rkiko=; b=K8PVDwNYvGI7exHxY7RI1aMiPOPowX0sul5JrEK04bFhf3Bk1aBjaUAqEgzvY4yZea /9qjorbe4YXRnN3rIkkqptnlwt6+6w1hQbZwP02kmWKP/zvew86mPjS2HanYno7Ni1+x VzZ06nTaf1DBaonpq+45oaLaPjc7/6IeWGZCkvaP8O5jBhVMHDaL1m03pMDyLNbeSU3a O0qHXQ6HPufq/pGCATIJ9OM/stykHIH2h/QTr5Mn3elKLKWJ3L+OpZyCyzFBvsXqq23S HLpiZc6aPdeRHI0sTCm1pxkN779bkY5pjSssYotfH5C1s476J76LmUVNz0cHbw41s0t9 Bscw== MIME-Version: 1.0 X-Received: by 10.52.156.72 with SMTP id wc8mr390350vdb.77.1358330269118; Wed, 16 Jan 2013 01:57:49 -0800 (PST) In-Reply-To: References: Date: Wed, 16 Jan 2013 17:57:49 +0800 Subject: Re: Python-list Digest, Vol 112, Issue 114 From: Levi Nie To: Python-list Digest Content-Type: multipart/alternative; boundary=bcaec53aef5c2db0bb04d364e9f1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 123 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358330272 news.xs4all.nl 6927 [2001:888:2000:d::a6]:60617 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36890 --bcaec53aef5c2db0bb04d364e9f1 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable TKS, Ulrich. I finally write some back (self.transport.write()), and shutdown the connections. > > ---------- =D2=D1=D7=AA=B7=A2=D3=CA=BC=FE ---------- > From: Ulrich Eckhardt > To: python-list@python.org > Cc: > Date: Tue, 15 Jan 2013 13:46:52 +0100 > Subject: Re: interrupt the file sending if the file size over the > quota...some errors here... > Am 15.01.2013 10:46, schrieb Levi Nie: > >> i want to interrupt the file sending. but i can't change the client. so = i >> need change the server. >> All things go well, but the message i wanna response seem not work. >> > > Ahem, what? It doesn't work, so does it sit on the couch all day? > > > is the self.transport.loseConnection(**) (the last line) blocking the >> messages? >> in fact, i work on Cumulus(nimbus project) which based on twisted. And i >> use s3cmd as the client. >> > > I'm wondering if questions concerning twisted don't have a better forum. > In any case, I can only comment on the general approach. For that, there > are two things you can do: > > 1. When receiving the the request header, you have a content length. If > that exceeds the allowed amount, shutdown() receiving and send an accordi= ng > HTTP response before closing the connection. > 2. If the data exceeds the amount advertised by the content length, close > the connection and discard the request. If you want to be nice, send an > according response before closing, but I personally wouldn't go to that > effort for broken HTTP clients. > > Concerning the question why your client hangs, it could also be the > sending. If you try to send something before receiving the full request, > client and server could enter a deadlock where each side waits for the > other to receive some data. For that reason, you should shutdown() > receiving in such a case. > > HTH > > Uli > > > > --bcaec53aef5c2db0bb04d364e9f1 Content-Type: text/html; charset=GB2312 Content-Transfer-Encoding: quoted-printable
TKS, Ulrich.
    I finally write some back (= self.transport.write()), and shutdown the connections.

---------- =D2=D1=D7=AA=B7=A2=D3=CA=BC=FE ----------
From: Ulri= ch Eckhardt <ulrich.e= ckhardt@dominolaser.com>
To: python-list@python.org
Cc: 
Date: Tue, 15 Jan 2013 13:46:52 +0100
Subject: Re= : interrupt the file sending if the file size over the quota...some errors = here...
Am 15.01.2013 10:46, schrieb Levi Nie:
i want to interrupt the file sending. but i can't change the client. so= i
need change the server.
All things go well, but the message i wanna response seem not work.

Ahem, what? It doesn't work, so does it sit on the couch all day?


is the self.transport.loseConnection() (the last line) blocking the<= br> messages?
in fact, i work on Cumulus(nimbus project) which based on twisted. And i use s3cmd as the client.

I'm wondering if questions concerning twisted don't have a better f= orum. In any case, I can only comment on the general approach. For that, th= ere are two things you can do:

1. When receiving the the request header, you have a content length. If tha= t exceeds the allowed amount, shutdown() receiving and send an according HT= TP response before closing the connection.
2. If the data exceeds the amount advertised by the content length, close t= he connection and discard the request. If you want to be nice, send an acco= rding response before closing, but I personally wouldn't go to that eff= ort for broken HTTP clients.

Concerning the question why your client hangs, it could also be the sending= . If you try to send something before receiving the full request, client an= d server could enter a deadlock where each side waits for the other to rece= ive some data. For that reason, you should shutdown() receiving in such a c= ase.

HTH

Uli



--bcaec53aef5c2db0bb04d364e9f1--