Skip to content

Commit 6ee09e6

Browse files
committed
fix: support yield object
1 parent fb93df0 commit 6ee09e6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

litefs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ def on_created(self, event):
461461

462462
class LiteFile(object):
463463

464-
def __init__(self, path, base, name, text):
464+
def __init__(self, path, base, name, text, status_code=200):
465+
self.status_code = int(status_code)
465466
self.path = path
466467
self.text = text
467468
self.etag = etag = sha1(text).hexdigest()
@@ -509,7 +510,8 @@ def handler(self, request):
509510
headers.append(("Etag", self.etag))
510511
text = self.text
511512
headers.append(("Content-Length", "%d" % len(text)))
512-
return request._response(200, headers=headers, content=text)
513+
return request._response(
514+
self.status_code, headers=headers, content=text)
513515

514516

515517
class TreeCache(object):
@@ -829,7 +831,6 @@ def start_response(self, status_code=200, headers=None):
829831
else:
830832
k, v = header
831833
response_headers[k] = v
832-
print('???', self.session_id, self.session.id)
833834
if self.session_id is None:
834835
self.set_cookie(default_sid, self.session.id, path="/")
835836
self._headers_responsed = True
@@ -876,7 +877,7 @@ def _cast(self, s=None):
876877
if is_bytes(first):
877878
new_iter_s = itertools.chain([first], iter_s)
878879
elif is_unicode(first):
879-
encoder = lambda item: item.encode("utf-8")
880+
encoder = lambda item: str(item).encode("utf-8")
880881
new_iter_s = itertools.chain([first], iter_s)
881882
new_iter_s = imap(encoder, new_iter_s)
882883
else:
@@ -1001,6 +1002,7 @@ def handler(self):
10011002
litefile = None
10021003
if litefile is not None:
10031004
app.files.put(path, litefile)
1005+
litefile.status_code = 404
10041006
try:
10051007
return litefile.handler(self)
10061008
except:

0 commit comments

Comments
 (0)