|
48 | 48 | from subprocess import Popen, PIPE |
49 | 49 | from tempfile import NamedTemporaryFile, TemporaryFile |
50 | 50 | from time import time, strftime, gmtime |
51 | | -from traceback import print_exc |
52 | 51 | from urllib import splitport, unquote_plus |
53 | 52 | from UserDict import UserDict |
54 | 53 | from uuid import uuid4 |
@@ -614,10 +613,42 @@ def session_id(self): |
614 | 613 | def session(self): |
615 | 614 | return self._session |
616 | 615 |
|
| 616 | + @property |
| 617 | + def request_method(self): |
| 618 | + return self.environ['REQUEST_METHOD'] |
| 619 | + |
| 620 | + @property |
| 621 | + def server_protocol(self): |
| 622 | + return self.environ['SERVER_PROTOCOL'] |
| 623 | + |
617 | 624 | @property |
618 | 625 | def path_info(self): |
619 | 626 | return self.environ['PATH_INFO'] |
620 | 627 |
|
| 628 | + @property |
| 629 | + def query_string(self): |
| 630 | + return self.environ['QUERY_STRING'] |
| 631 | + |
| 632 | + @property |
| 633 | + def request_uri(self): |
| 634 | + environ = self.environ |
| 635 | + path_info = environ['PATH_INFO'] |
| 636 | + query_string = environ['QUERY_STRING'] |
| 637 | + if not query_string: |
| 638 | + return path_info |
| 639 | + return '?'.join((path_info, query_string)) |
| 640 | + |
| 641 | + @property |
| 642 | + def referer(self): |
| 643 | + return self.environ.get('HTTP_REFERER') |
| 644 | + |
| 645 | + @property |
| 646 | + def cookie(self): |
| 647 | + cookie_str = self.environ.get('HTTP_COOKIE', '') |
| 648 | + cookie = SimpleCookie() |
| 649 | + cookie.load(cookie_str) |
| 650 | + return cookie |
| 651 | + |
621 | 652 | def start_response(self, status_code=200, headers=None): |
622 | 653 | buffers = self._buffers |
623 | 654 | if self._headers_responsed: |
@@ -1033,7 +1064,7 @@ class Litefs(object): |
1033 | 1064 |
|
1034 | 1065 | def __init__(self, **kwargs): |
1035 | 1066 | self.config = config = make_config(**kwargs) |
1036 | | - level = logging.ERROR if config.debug else logging.DEBUG |
| 1067 | + level = logging.DEBUG if config.debug else logging.ERROR |
1037 | 1068 | self.logger = make_logger(__name__, level=level) |
1038 | 1069 | self.server_info = server_info = make_server( |
1039 | 1070 | config.address, request_size=config.request_size |
|
0 commit comments