Ticket #288: http_request_args_property.diff
File http_request_args_property.diff, 2.6 KB (added by , 13 years ago) |
---|
-
twisted/web/http.py
535 535 sentLength = 0 # content-length of response, or total bytes sent via chunking 536 536 etag = None 537 537 lastModified = None 538 args = None538 _args = None 539 539 path = None 540 540 content = None 541 541 _forceSSL = 0 … … 693 693 @param version: The HTTP version of this request. 694 694 """ 695 695 self.content.seek(0,0) 696 self.args = {}697 696 self.stack = [] 698 697 699 698 self.method, self.uri = command, path 700 699 self.clientproto = version 701 700 x = self.uri.split('?', 1) 702 703 701 if len(x) == 1: 704 702 self.path = self.uri 705 703 else: 706 704 self.path, argstring = x 707 self.args = parse_qs(argstring, 1)708 705 709 706 # cache the client and server information, we'll need this later to be 710 707 # serialized and sent with the request so CGIs will work remotely 711 708 self.client = self.channel.transport.getPeer() 712 709 self.host = self.channel.transport.getHost() 710 711 self.process() 713 712 713 @property 714 def args(self): 715 if(self._args is not None): 716 return self._args 717 718 x = self.uri.split('?', 1) 719 if len(x) != 1: 720 self._args = parse_qs(x[1], 1) 721 714 722 # Argument processing 715 args = self.args 723 if(self._args is None): 724 self._args = {} 725 args = self._args 716 726 ctype = self.requestHeaders.getRawHeaders('content-type') 717 727 if ctype is not None: 718 728 ctype = ctype[0] … … 737 747 return 738 748 raise 739 749 self.content.seek(0, 0) 740 741 self.process() 742 743 750 751 return self._args 752 744 753 def __repr__(self): 745 754 return '<%s %s %s>'% (self.method, self.uri, self.clientproto) 746 755 -
twisted/web/test/test_web.py
20 20 from twisted.python import log 21 21 22 22 23 class DummyRequest :23 class DummyRequest(http.Request): 24 24 """ 25 25 Represents a dummy or fake request. 26 26 … … 64 64 self.prepath = [] 65 65 self.session = None 66 66 self.protoSession = session or server.Session(0, self) 67 self. args = {}67 self._args = None 68 68 self.outgoingHeaders = {} 69 69 self.responseHeaders = http_headers.Headers() 70 70 self.responseCode = None