Skip to content

Commit 4fc2881

Browse files
committed
修改部分bug
1 parent d43673c commit 4fc2881

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

litefs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from cStringIO import StringIO
2626
from errno import ENOTCONN, EMFILE, EWOULDBLOCK, EAGAIN
2727
from functools import partial
28-
from greenlet import greenlet, getcurrent
28+
from greenlet import greenlet, getcurrent, GreenletExit
2929
from gzip import GzipFile
3030
from hashlib import sha1
3131
from httplib import responses as http_status_codes
@@ -65,6 +65,8 @@
6565
default_request_size = 10240
6666
default_litefs_sid = '%s.sid' % default_prefix
6767

68+
server_name = 'litefs %s' % __version__
69+
EOFS = ('', '\n', '\r\n')
6870
date_format = '%Y/%m/%d %H:%M:%S'
6971
should_retry_error = (EWOULDBLOCK, EAGAIN)
7072
double_slash_sub = re.compile(r'\/{2,}').sub
@@ -173,7 +175,7 @@ def make_server(address, request_size=-1):
173175

174176
def make_environ(app, rwpair, address):
175177
environ = {}
176-
environ['SERVER_NAME'] = platform()
178+
environ['SERVER_NAME'] = server_name
177179
environ['SERVER_PORT'] = int(app.server_info['port'])
178180
s = rwpair.readline(DEFAULT_BUFFER_SIZE)
179181
if not s:
@@ -197,7 +199,7 @@ def make_environ(app, rwpair, address):
197199
environ['PATH_INFO'] = path_info
198200
s = rwpair.readline(DEFAULT_BUFFER_SIZE)
199201
while True:
200-
if s in ('', '\n', '\r\n'):
202+
if s in EOFS:
201203
break
202204
k, v = s.split(':', 1)
203205
k, v = k.strip(), v.strip()
@@ -229,7 +231,7 @@ def make_environ(app, rwpair, address):
229231
disposition = headers['CONTENT-DISPOSITION']
230232
h, m, t = disposition.split(';')
231233
name = m.split('=')[1].strip()
232-
if size <= (5 * 1024 * 1024):
234+
if size <= 5242880: # <= 5M file save in memory
233235
fp = StringIO()
234236
else:
235237
fp = TemporaryFile(mode='w+b')
@@ -1052,7 +1054,7 @@ def request_handler(self, fileno, raw, address):
10521054
Response(self, request, address).handler()
10531055
except socket.error as e:
10541056
if e.errno == errno.EPIPE:
1055-
raise greenlet.GreenletExit
1057+
raise GreenletExit
10561058
raise
10571059
except Exception as e:
10581060
if not isinstance(e, HttpError):

0 commit comments

Comments
 (0)