aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod
diff options
context:
space:
mode:
Diffstat (limited to 'libpathod')
-rw-r--r--libpathod/cmdline.py2
-rw-r--r--libpathod/language.py9
-rw-r--r--libpathod/pathoc.py37
-rw-r--r--libpathod/pathod.py3
4 files changed, 28 insertions, 23 deletions
diff --git a/libpathod/cmdline.py b/libpathod/cmdline.py
index 3323716c..bd6a4360 100644
--- a/libpathod/cmdline.py
+++ b/libpathod/cmdline.py
@@ -4,8 +4,8 @@ import os
import os.path
import sys
import re
-from . import pathoc, pathod, version, utils, language
from netlib import http_uastrings
+from . import pathoc, pathod, version, utils, language
def args_pathoc(argv, stdout=sys.stdout, stderr=sys.stderr):
diff --git a/libpathod/language.py b/libpathod/language.py
index 7aa6565c..5c53453d 100644
--- a/libpathod/language.py
+++ b/libpathod/language.py
@@ -51,7 +51,7 @@ def send_chunk(fp, val, blocksize, start, end):
return end-start
-def write_values(fp, vals, actions, sofar=0, skip=0, blocksize=BLOCKSIZE):
+def write_values(fp, vals, actions, sofar=0, blocksize=BLOCKSIZE):
"""
vals: A list of values, which may be strings or Value objects.
@@ -235,7 +235,7 @@ class _Token(object):
"""
__metaclass__ = abc.ABCMeta
- @abc.abstractmethod
+ @classmethod
def expr(klass): # pragma: no cover
"""
A parse expression.
@@ -709,7 +709,7 @@ class _Action(_Token):
pass
@abc.abstractmethod
- def intermediate(self): # pragma: no cover
+ def intermediate(self, settings): # pragma: no cover
pass
@@ -791,6 +791,7 @@ class InjectAt(_Action):
class _Message(object):
__metaclass__ = abc.ABCMeta
version = "HTTP/1.1"
+ logattrs = []
def __init__(self, tokens):
self.tokens = tokens
@@ -873,7 +874,7 @@ class _Message(object):
def preamble(self, settings): # pragma: no cover
pass
- @abc.abstractmethod
+ @classmethod
def expr(klass): # pragma: no cover
pass
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index 08efdb3d..616550fa 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -116,6 +116,7 @@ class Pathoc(tcp.TCPClient):
self.clientcert = clientcert
self.sslversion = utils.SSLVERSIONS[sslversion]
self.ciphers = ciphers
+ self.sslinfo = None
self.showreq = showreq
self.showresp = showresp
@@ -187,6 +188,8 @@ class Pathoc(tcp.TCPClient):
r: A language.Request object, or a string representing one request.
Returns True if we have a non-ignored response.
+
+ May raise http.HTTPError, tcp.NetLibError
"""
if isinstance(r, basestring):
r = language.parse_requests(r)[0]
@@ -203,7 +206,6 @@ class Pathoc(tcp.TCPClient):
self.address.host
)
self.wfile.flush()
-
resp = list(http.read_response(self.rfile, r.method.string(), None))
resp.append(self.sslinfo)
resp = Response(*resp)
@@ -224,22 +226,25 @@ class Pathoc(tcp.TCPClient):
finally:
if req:
if self.ignorecodes and resp and resp.status_code in self.ignorecodes:
- return None
-
- if self.explain:
- print >> self.fp, ">> Spec:", r.spec()
+ resp = None
+ else:
+ if self.explain:
+ print >> self.fp, ">> Spec:", r.spec()
- if self.showreq:
- self._show(
- self.fp, ">> Request", self.wfile.get_log(), self.hexdump
- )
+ if self.showreq:
+ self._show(
+ self.fp, ">> Request", self.wfile.get_log(), self.hexdump
+ )
- if self.showsummary and resp:
- self._show_summary(self.fp, resp)
- if self.showresp:
- self._show(
- self.fp, "<< Response", self.rfile.get_log(), self.hexdump
- )
+ if self.showsummary and resp:
+ self._show_summary(self.fp, resp)
+ if self.showresp:
+ self._show(
+ self.fp,
+ "<< Response",
+ self.rfile.get_log(),
+ self.hexdump
+ )
return resp
@@ -310,7 +315,7 @@ def main(args): # pragma: nocover
sys.stdout.flush()
if ret and args.oneshot:
return
- except (http.HttpError, tcp.NetlibError), v:
+ except (http.HttpError, tcp.NetLibError), v:
pass
except KeyboardInterrupt:
pass
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index de6bde3a..07354aa8 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -233,7 +233,7 @@ class PathodHandler(tcp.BaseHandler):
def handle(self):
if self.server.ssl:
try:
- cert, key, chain_file = self.server.ssloptions.get_cert(None)
+ cert, key, _ = self.server.ssloptions.get_cert(None)
self.convert_to_ssl(
cert, key,
handle_sni=self.handle_sni,
@@ -276,7 +276,6 @@ class Pathod(tcp.TCPServer):
def __init__(
self,
addr,
- confdir=CONFDIR,
ssl=False,
ssloptions=None,
craftanchor="/p/",