aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/language/http.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-05-03 08:51:57 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-05-03 08:51:57 +1200
commita46e17459d6afa9b9da1e29dd2831c760c8868da (patch)
tree93989353577f83509fabe34e31805c048e06e9e6 /libpathod/language/http.py
parent5d5f2bdd1f2354b9a1b204964fa05488772695f8 (diff)
downloadmitmproxy-a46e17459d6afa9b9da1e29dd2831c760c8868da.tar.gz
mitmproxy-a46e17459d6afa9b9da1e29dd2831c760c8868da.tar.bz2
mitmproxy-a46e17459d6afa9b9da1e29dd2831c760c8868da.zip
Language: minor refactoring and whitespace
Diffstat (limited to 'libpathod/language/http.py')
-rw-r--r--libpathod/language/http.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/libpathod/language/http.py b/libpathod/language/http.py
index c1c2ae96..f926a8cf 100644
--- a/libpathod/language/http.py
+++ b/libpathod/language/http.py
@@ -81,7 +81,7 @@ class ShortcutUserAgent(_HeaderMixin, base.OptionsOrValue):
self.value.val.lower()
)[2]
else:
- value = self.value
+ value = self.value.val
return self.format_header(
self.key.get_generator(settings),
value
@@ -129,7 +129,7 @@ class _HTTPMessage(message.Message):
vals.extend(h.values(settings))
vals.append("\r\n")
if self.body:
- vals.append(self.body.value.get_generator(settings))
+ vals.extend(self.body.values(settings))
return vals
@@ -169,11 +169,9 @@ class Response(_HTTPMessage):
l.extend(self.reason.values(settings))
else:
l.append(
- generators.LiteralGenerator(
- http_status.RESPONSES.get(
- code,
- "Unknown code"
- )
+ http_status.RESPONSES.get(
+ code,
+ "Unknown code"
)
)
return l
@@ -205,7 +203,9 @@ class Response(_HTTPMessage):
if not self.body:
length = 0
else:
- length = len(self.body.value.get_generator(settings))
+ length = sum(
+ len(i) for i in self.body.values(settings)
+ )
tokens.append(
Header(
base.ValueLiteral("Content-Length"),
@@ -301,7 +301,9 @@ class Request(_HTTPMessage):
if not self.raw:
if not get_header("Content-Length", self.headers):
if self.body:
- length = len(self.body.value.get_generator(settings))
+ length = sum(
+ len(i) for i in self.body.values(settings)
+ )
tokens.append(
Header(
base.ValueLiteral("Content-Length"),