prettify html docs

This commit is contained in:
Thomas Kriechbaumer 2015-06-22 15:12:20 +02:00
parent 5c0f0c2c22
commit 01f0982968
23 changed files with 641 additions and 656 deletions

View File

@ -1,18 +1,12 @@
{% extends "frame.html" %}
{% block body %}
{% extends "frame.html" %} {% block body %}
<section>
<div class="page-header">
<h1>
About
</h1>
<h1>About</h1>
</div>
<div class="row">
<div class="span6">
<div>
<p>pathod is developed by <a href="http://corte.si">Aldo
Cortesi</a>.</p>
<p>pathod is developed by <a href="http://corte.si">Aldo Cortesi</a>.</p>
</div>
<div>
@ -25,6 +19,4 @@
</div>
</div>
</section>
{% endblock %}

View File

@ -1,10 +1,11 @@
{% extends "layout.html" %}
{% macro subs(s) %}
{% if subsection == s %} class="active" {% endif %}
{% if subsection == s %}
class="active"
{% endif %}
{% endmacro %}
{% block content %}
<div class="row">
<div class="span3">
@ -19,8 +20,7 @@
</div>
</div>
<div class="span9">
{% block body %}
{% endblock %}
{% block body %} {% endblock %}
</div>
</div>
{% endblock %}

View File

@ -1,6 +1,4 @@
{% extends "docframe.html" %}
{% block body %}
{% extends "docframe.html" %} {% block body %}
<div class="page-header">
<h1>
Language Spec
@ -34,8 +32,10 @@
<a id="offsetspec"></a>
<h2>OFFSET</h2>
<p>Offsets are calculated relative to the base message, before any
injections or other transforms are applied. They have 3 flavors:</p>
<p>
Offsets are calculated relative to the base message, before any injections or other transforms
are applied. They have 3 flavors:
</p>
<ul>
<li>An integer byte offset </li>
@ -52,8 +52,10 @@
<pre class="example">"foo"</pre>
<p>Either single or double quotes are accepted, and quotes can be escaped with
backslashes within the string:</p>
<p>
Either single or double quotes are accepted, and quotes can be escaped with backslashes
within the string:
</p>
<pre class="example">'fo\'o'</pre>
@ -61,18 +63,21 @@
<pre class="example">'foo\r\nbar'</pre>
<h3>Files</h3>
<p>You can load a value from a specified file path. To do so, you have to specify
a _staticdir_ option to pathod on the command-line, like so: </p>
<p>
You can load a value from a specified file path. To do so, you have to specify a _staticdir_
option to pathod on the command-line, like so:
</p>
<pre class="example">pathod -d ~/myassets</pre>
<p>All paths are relative paths under this directory. File loads are indicated by
starting the value specifier with the left angle bracket:
<p>
All paths are relative paths under this directory. File loads are indicated by starting
the value specifier with the left angle bracket:
</p>
<pre class="example">&lt;my/path</pre></p>
<pre class="example">&lt;my/path</pre>
<p>The path value can also be a quoted string, with the same syntax as literals:</p>
@ -81,45 +86,58 @@
<h3>Generated values</h3>
<p>An @-symbol lead-in specifies that generated data should be used. There are two
components to a generator specification - a size, and a data type. By default
pathod assumes a data type of "bytes". </p>
<p>
An @-symbol lead-in specifies that generated data should be used. There are two components
to a generator specification - a size, and a data type. By default pathod assumes
a data type of "bytes".
</p>
<p>Here's a value specifier for generating 100 bytes:
<pre class="example">@100</pre></p>
<pre class="example">@100</pre>
</p>
<p>You can use standard suffixes to indicate larger values. Here, for instance, is
a specifier for generating 100 megabytes:</p>
<p>
You can use standard suffixes to indicate larger values. Here, for instance, is a specifier
for generating 100 megabytes:
</p>
<pre class="example">@100m</pre>
<p>Data is generated and served efficiently - if you really want to send a
terabyte of data to a client, pathod can do it. The supported suffixes are:</p>
<p>
Data is generated and served efficiently - if you really want to send a terabyte of data
to a client, pathod can do it. The supported suffixes are:
</p>
<table class="table table-bordered">
<tbody>
<tr>
<td>b</td> <td>1024**0 (bytes)</td>
<td>b</td>
<td>1024**0 (bytes)</td>
</tr>
<tr>
<td>k</td> <td>1024**1 (kilobytes)</td>
<td>k</td>
<td>1024**1 (kilobytes)</td>
</tr>
<tr>
<td>m</td> <td>1024**2 (megabytes)</td>
<td>m</td>
<td>1024**2 (megabytes)</td>
</tr>
<tr>
<td>g</td> <td>1024**3 (gigabytes)</td>
<td>g</td>
<td>1024**3 (gigabytes)</td>
</tr>
<tr>
<td>t</td> <td>1024**4 (terabytes)</td>
<td>t</td>
<td>1024**4 (terabytes)</td>
</tr>
</tbody>
</table>
<p>Data types are separated from the size specification by a comma. This
specification generates 100mb of ASCII:</p>
<p>
Data types are separated from the size specification by a comma. This specification generates
100mb of ASCII:
</p>
<pre class="example">@100m,ascii</pre>
@ -162,7 +180,8 @@
<tr>
<td>punctuation</td>
<td>
<pre>!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~</pre>
<pre>!"#$%&\'()*+,-./:;
<=>?@[\\]^_`{|}~</pre>
</td>
</tr>
<tr>
@ -174,5 +193,4 @@
</tbody>
</table>
</section>
{% endblock %}

View File

@ -1,4 +1,5 @@
<pre class="example">wf:[colon-separated list of features]</pre></p>
<pre class="example">wf:[colon-separated list of features]</pre>
</p>
<table class="table table-bordered">
<tbody>
@ -6,8 +7,7 @@
<tr>
<td> b<a href="#valuespec">VALUE</a> </td>
<td>
Set the frame payload. If a masking key is present, the
value is encoded automatically.
Set the frame payload. If a masking key is present, the value is encoded automatically.
</td>
</tr>
@ -15,8 +15,8 @@
<td> c<a href="#valuespec">INTEGER</a> </td>
<td>
Set the op code. This can either be an integer from 0-15, or be
one of the following opcode names: <b>text</b> (the default),
Set the op code. This can either be an integer from 0-15, or be one of the following opcode
names: <b>text</b> (the default),
<b>continue</b>, <b>binary</b>, <b>close</b>, <b>ping</b>,
<b>pong</b>.
@ -47,17 +47,16 @@
<tr>
<td> k<a href="#valuespec">VALUE</a> </td>
<td>
Set the masking key. The resulting value must be exactly 4
bytes long. The special form <b>knone</b> specifies that no key
should be set, even if the mask bit is on.
Set the masking key. The resulting value must be exactly 4 bytes long. The special form
<b>knone</b> specifies that no key should be set, even
if the mask bit is on.
</td>
</tr>
<tr>
<td> l<a href="#valuespec">INTEGER</a> </td>
<td>
Set the payload length in the frame header, regardless of the
actual body length.
Set the payload length in the frame header, regardless of the actual body length.
</td>
</tr>
@ -71,16 +70,15 @@
<tr>
<td> p<a href="#offsetspec">OFFSET</a>,SECONDS </td>
<td>
Pause for SECONDS seconds after OFFSET bytes. SECONDS can
be an integer or "f" to pause forever.
Pause for SECONDS seconds after OFFSET bytes. SECONDS can be an integer or "f" to pause
forever.
</td>
</tr>
<tr>
<td> r<a href="#valuespec">VALUE</a> </td>
<td>
Set the raw frame payload. This disables masking, even if the
key is present.
Set the raw frame payload. This disables masking, even if the key is present.
</td>
</tr>

View File

@ -1,6 +1,4 @@
{% extends "docframe.html" %}
{% block body %}
{% extends "docframe.html" %} {% block body %}
<div class="page-header">
<h1>
libpathod
@ -10,18 +8,16 @@
<div class="row">
<div class="span6">
<p> Behind the pathod and pathoc command-line tools lurks
<b>libpathod</b>, a powerful library for manipulating and serving HTTP
requests and responses. The canonical documentation for the library is
in the code, and can be accessed using pydoc.</p>
<p>
Behind the pathod and pathoc command-line tools lurks <b>libpathod</b>, a
powerful library for manipulating and serving HTTP requests and responses.
The canonical documentation for the library is in the code, and can be accessed
using pydoc.
</p>
</div>
<div class="span6">
<h1>pathoc</h1>
{% include "libpathod_pathoc.html" %}
</div>
</div>
{% endblock %}

View File

@ -1,5 +1,4 @@
{% extends "docframe.html" %}
{% block body %}
{% extends "docframe.html" %} {% block body %}
<div class="page-header">
<h1>
pathoc
@ -7,12 +6,14 @@
</h1>
</div>
<p>Pathoc is a perverse HTTP daemon designed to let you craft almost any
conceivable HTTP request, including ones that creatively violate the standards.
HTTP requests are specified using a <a href="/docs/language">small, terse
language</a>, which pathod shares with its server-side twin <a
href="/docs/pathod">pathod</a>. To view pathoc's complete range of options, use
the command-line help:</p>
<p>
Pathoc is a perverse HTTP daemon designed to let you craft almost any conceivable HTTP
request, including ones that creatively violate the standards. HTTP requests are specified
using a
<a href="/docs/language">small, terse language</a>, which pathod shares with its server-side
twin <a href="/docs/pathod">pathod</a>. To view pathoc's complete range of options,
use the command-line help:
</p>
<pre class="terminal">pathoc --help</pre>
@ -25,21 +26,25 @@ the command-line help:</p>
<pre class="terminal">pathoc hostname request [request ...]</pre>
<p>That is, we specify the hostname to connect to, followed by one or more
requests. Lets start with a simple example:</p>
<p>
That is, we specify the hostname to connect to, followed by one or more requests. Lets
start with a simple example:
</p>
<pre class="terminal">&gt; pathoc google.com get:/
&lt;&lt; 301 Moved Permanently: 219 bytes</pre>
<pre class="terminal">
&gt; pathoc google.com get:/ &lt;&lt; 301 Moved Permanently: 219 bytes
</pre>
<p>Here, we make a GET request to the path / on port 80 of google.com.
Pathoc's output tells us that the server responded with a 301. We can tell
pathoc to connect using SSL, in which case the default port is changed to
443 (you can over-ride the default port with the <b>-p</b> command-line
option):</p>
<pre class="terminal">&gt; pathoc -s google.com get:/
&lt;&lt; 301 Moved Permanently: 219 bytes</pre>
<p>
Here, we make a GET request to the path / on port 80 of google.com. Pathoc's output tells
us that the server responded with a 301. We can tell pathoc to connect using SSL,
in which case the default port is changed to 443 (you can over-ride the default
port with the <b>-p</b> command-line option):
</p>
<pre class="terminal">
&gt; pathoc -s google.com get:/ &lt;&lt; 301 Moved Permanently: 219 bytes
</pre>
</section>
@ -48,35 +53,40 @@ the command-line help:</p>
<h1>Multiple Requests</h1>
</div>
<p>There are two ways to tell pathoc to issue multiple requests. The first
is to specify them on the command-line, like so:</p>
<p>
There are two ways to tell pathoc to issue multiple requests. The first is to specify
them on the command-line, like so:
</p>
<pre class="terminal">&gt; pathoc google.com get:/ get:/
&lt;&lt; 301 Moved Permanently: 219 bytes
&lt;&lt; 301 Moved Permanently: 219 bytes</pre>
<pre class="terminal">
&gt; pathoc google.com get:/ get:/ &lt;&lt; 301 Moved Permanently: 219 bytes &lt;&lt;
301 Moved Permanently: 219 bytes
</pre>
<p> In this case, pathoc issues the specified requests over the same TCP
connection - so in the above example only one connection is made to
google.com </p>
<p>
In this case, pathoc issues the specified requests over the same TCP connection - so in
the above example only one connection is made to google.com
</p>
<p>The other way to issue multiple requets is to use the <b>-n</b> flag:</p>
<pre class="terminal">&gt; pathoc -n 2 google.com get:/
&lt;&lt; 301 Moved Permanently: 219 bytes
&lt;&lt; 301 Moved Permanently: 219 bytes</pre>
<pre class="terminal">
&gt; pathoc -n 2 google.com get:/ &lt;&lt; 301 Moved Permanently: 219 bytes &lt;&lt; 301
Moved Permanently: 219 bytes
</pre>
<p> The output is identical, but two separate TCP connections are made to
the upstream server. These two specification styles can be combined:</p>
<p>
The output is identical, but two separate TCP connections are made to the upstream server.
These two specification styles can be combined:
</p>
<pre class="terminal">&gt; pathoc -n 2 google.com get:/ get:/
&lt;&lt; 301 Moved Permanently: 219 bytes
&lt;&lt; 301 Moved Permanently: 219 bytes
&lt;&lt; 301 Moved Permanently: 219 bytes
&lt;&lt; 301 Moved Permanently: 219 bytes</pre>
<p> Here, two distinct TCP connections are made, with two requests issued
over each. </p>
<pre class="terminal">
&gt; pathoc -n 2 google.com get:/ get:/ &lt;&lt; 301 Moved Permanently: 219 bytes &lt;&lt;
301 Moved Permanently: 219 bytes &lt;&lt; 301 Moved Permanently: 219 bytes &lt;&lt;
301 Moved Permanently: 219 bytes
</pre>
<p>Here, two distinct TCP connections are made, with two requests issued over each.</p>
</section>
@ -85,67 +95,79 @@ the command-line help:</p>
<h1>Basic Fuzzing</h1>
</div>
<p>The combination of pathoc's powerful request specification language and
a few of its command-line options makes for quite a powerful basic fuzzer.
Here's an example:</p>
<p>
The combination of pathoc's powerful request specification language and a few of its command-line
options makes for quite a powerful basic fuzzer. Here's an example:
</p>
<pre class="terminal">&gt; pathoc -e -I 200 -t 2 -n 1000 localhost get:/:b@10:ir,@1</pre>
<pre class="terminal">
&gt; pathoc -e -I 200 -t 2 -n 1000 localhost get:/:b@10:ir,@1
</pre>
<p>The request specified here is a valid GET with a body consisting of 10
random bytes, but with 1 random byte inserted in a random place. This could
be in the headers, in the initial request line, or in the body itself.
There are a few things to note here:<p>
<p>
The request specified here is a valid GET with a body consisting of 10 random bytes, but
with 1 random byte inserted in a random place. This could be in the headers, in
the initial request line, or in the body itself. There are a few things to note
here:
</p>
<ul>
<li>
Corrupting the request in this way will often make the server enter a state where it's
awaiting more input from the client. This is where the
<b>-t</b> option comes in, which sets a timeout that causes pathoc to disconnect
after two seconds.
</li>
<li> Corrupting the request in this way will often make the server
enter a state where it's awaiting more input from the client. This is
where the <b>-t</b> option comes in, which sets a timeout that causes
pathoc to disconnect after two seconds. </li>
<li>
The <b>-n</b> option tells pathoc to repeat the request 1000 times.
</li>
<li> The <b>-n</b> option tells pathoc to repeat the request 1000
times.</li>
<li> The <b>-I</b> option tells pathoc to ignore HTTP 200 response
codes. You can use this to fine-tune what pathoc considers to be an
exceptional condition, and therefore log-worthy.</li>
<li> The <b>-e</b> option tells pathoc to print an explanation of each
logged request, in the form of an expanded pathoc specification with
all random portions and automatic header additions resolved. This lets
you precisely replay a request that triggered an error </li>
<li>
The <b>-I</b> option tells pathoc to ignore HTTP 200 response codes. You can
use this to fine-tune what pathoc considers to be an exceptional condition,
and therefore log-worthy.
</li>
<li>
The <b>-e</b> option tells pathoc to print an explanation of each logged request,
in the form of an expanded pathoc specification with all random portions and
automatic header additions resolved. This lets you precisely replay a request
that triggered an error.
</li>
</ul>
</section>
<section>
<div class="page-header">
<h1>Interacting with Proxies</h1>
</div>
<p>Pathoc has a reasonably sophisticated suite of features for interacting
with proxies. The proxy request syntax very closely mirrors that of
straight HTTP, which means that it is possible to make proxy-style requests
using pathoc without any additional syntax, by simply specifying a full URL
instead of a simple path::</p>
<p>
Pathoc has a reasonably sophisticated suite of features for interacting with proxies.
The proxy request syntax very closely mirrors that of straight HTTP, which means
that it is possible to make proxy-style requests using pathoc without any additional
syntax, by simply specifying a full URL instead of a simple path:
</p>
<pre class="terminal">&gt; pathoc -p 8080 localhost "get:'http://google.com'"</pre>
<p>Another common use case is to use an HTTP CONNECT request to probe
remote servers via a proxy. This is done with the <b>-c</b> command-line
option, which allows you to specify a remote host and port pair:</p>
<p>
Another common use case is to use an HTTP CONNECT request to probe remote servers via
a proxy. This is done with the <b>-c</b> command-line option, which allows
you to specify a remote host and port pair:
</p>
<pre class="terminal">&gt; pathoc -c google.com:80 -p 8080 localhost get:/</pre>
<p>Note that pathoc does <b>not</b> negotiate SSL without being explictly
instructed to do so. If you're making a CONNECT request to an SSL-protected
resource, you must also pass the <b>-s</b> flag:</p>
<p>
Note that pathoc does <b>not</b> negotiate SSL without being explictly instructed
to do so. If you're making a CONNECT request to an SSL-protected resource, you
must also pass the <b>-s</b> flag:
</p>
<pre class="terminal">&gt; pathoc -sc google.com:443 -p 8080 localhost get:/</pre>
</section>
@ -154,38 +176,34 @@ the command-line help:</p>
<h1>Embedded response specification</h1>
</div>
<p>One interesting feature of the Request sppecification language is that
you can embed a response specifcation in it, which is then added to the
request path. Here's an example:</p>
<p>
One interesting feature of the Request sppecification language is that you can embed a
response specifcation in it, which is then added to the request path. Here's an
example:
</p>
<pre class="terminal">&gt; pathoc localhost:9999 "get:/p/:s'401:ir,@1'"</pre>
<p> This crafts a request that connects to the pathod server, and which then
crafts a response that generates a 401, with one random byte embedded at a
random point. The response specification is parsed and expanded by pathoc,
so you see syntax errors immediately. This really becomes handy when
combined with the <b>-e</b> flag to show the expanded request:
<p>
This crafts a request that connects to the pathod server, and which then crafts a response
that generates a 401, with one random byte embedded at a random point. The response
specification is parsed and expanded by pathoc, so you see syntax errors immediately.
This really becomes handy when combined with the <b>-e</b> flag to show
the expanded request:
</p>
<pre class="terminal">&gt; > pathoc -e localhost:9999 "get:/p/:s'401:ir,@1'"
>> Spec: get:/p/:s'401:i15,\'o\':h\'Content-Length\'=\'0\'':h'Content-Length'='0'
<pre class="terminal">
&gt; > pathoc -e localhost:9999 "get:/p/:s'401:ir,@1'" >> Spec: get:/p/:s'401:i15,\'o\':h\'Content-Length\'=\'0\'':h'Content-Length'='0'
<< 401 Unoauthorized: 0 bytes </pre>
<p> Note that the embedded response has been resolved <i>before</i> being
sent to the server, so that "ir,@1" (embed a random byte at a random
location) has become "i15,\'o\'" (embed the character "o" at offset 15). You
now have a pathoc request specification that is precisely reproducable, even
with random components. This feature comes in terribly handy when testing a
proxy, since you can now drive the server repsonse completely from the
client, and have a complete log of reproducible requests to analyse
afterwards.</p>
<p>
Note that the embedded response has been resolved <i>before</i> being
sent to the server, so that "ir,@1" (embed a random byte at a random location)
has become "i15,\'o\'" (embed the character "o" at offset 15). You now
have a pathoc request specification that is precisely reproducable, even
with random components. This feature comes in terribly handy when testing
a proxy, since you can now drive the server repsonse completely from the
client, and have a complete log of reproducible requests to analyse afterwards.
</p>
</section>
{% endblock %}

View File

@ -1,6 +1,4 @@
{% extends "docframe.html" %}
{% block body %}
{% extends "docframe.html" %} {% block body %}
<div class="page-header">
<h1>
pathod
@ -8,11 +6,13 @@
</h1>
</div>
<p>Pathod is a pathological HTTP daemon designed to let you craft almost any
conceivable HTTP response, including ones that creatively violate the
standards. HTTP responses are specified using a <a href="/docs/language">small,
terse language</a>, which pathod shares with its evil twin <a
href="/docs/pathoc">pathoc</a>. </p>
<p>
Pathod is a pathological HTTP daemon designed to let you craft almost any conceivable
HTTP response, including ones that creatively violate the standards. HTTP responses
are specified using a
<a href="/docs/language">small, terse language</a>, which pathod shares with its evil
twin <a href="/docs/pathoc">pathoc</a>.
</p>
<section>
<div class="page-header">
@ -23,23 +23,29 @@ href="/docs/pathoc">pathoc</a>. </p>
<pre class="terminal">./pathod</pre>
<p>By default, the service listens on port 9999 of localhost. Pathod's
documentation is self-hosting, and the pathod daemon exposes an interface that
lets you play with the specifciation language, preview what responses and
requests would look like on the wire, and view internal logs. To access all of
this, just fire up your browser, and point it to the following URL:</p>
<p>
By default, the service listens on port 9999 of localhost. Pathod's documentation is self-hosting,
and the pathod daemon exposes an interface that lets you play with the specifciation
language, preview what responses and requests would look like on the wire, and
view internal logs. To access all of this, just fire up your browser, and point
it to the following URL:
</p>
<pre class="example">http://localhost:9999</pre>
<p>The default crafting anchor point is the path <b>/p/</b>. Anything after
this URL prefix is treated as a response specifier. So, hitting the following
URL will generate an HTTP 200 response with 100 bytes of random data:</p>
<p>
The default crafting anchor point is the path <b>/p/</b>. Anything after this
URL prefix is treated as a response specifier. So, hitting the following URL will
generate an HTTP 200 response with 100 bytes of random data:
</p>
<pre class="example">http://localhost:9999/p/200:b@100</pre>
<p>See the <a href="/docs/language">language documentation</a> to get (much)
fancier. The pathod daemon also takes a range of configuration options. To view
those, use the command-line help:</p>
<p>
See the <a href="/docs/language">language documentation</a> to get (much) fancier.
The pathod daemon also takes a range of configuration options. To view those,
use the command-line help:
</p>
<pre class="terminal">./pathod --help</pre>
@ -50,17 +56,19 @@ those, use the command-line help:</p>
<h1>Acting as a proxy</h1>
</div>
<p>Pathod automatically responds to both straight HTTP and proxy requests. For
proxy requests, the upstream host is ignored, and the path portion of the URL
is used to match anchors. This lets you test software that supports a proxy
configuration by spoofing responses from upstream servers.</p>
<p>By default, we treat all proxy CONNECT requests as HTTPS traffic, serving
the response using either pathod's built-in certificates, or the cert/key pair
specified by the user. You can over-ride this behaviour if you're testing a
client that makes a non-SSL CONNECT request using the -C command-line
option.</p>
<p>
Pathod automatically responds to both straight HTTP and proxy requests. For proxy requests,
the upstream host is ignored, and the path portion of the URL is used to match
anchors. This lets you test software that supports a proxy configuration by spoofing
responses from upstream servers.
</p>
<p>
By default, we treat all proxy CONNECT requests as HTTPS traffic, serving the response
using either pathod's built-in certificates, or the cert/key pair specified by
the user. You can over-ride this behaviour if you're testing a client that makes
a non-SSL CONNECT request using the -C command-line option.
</p>
</section>
@ -69,16 +77,18 @@ option.</p>
<h1>Anchors</h1>
</div>
<p>Anchors provide an alternative to specifying the response in the URL.
Instead, you attach a response to a pre-configured anchor point, specified with
a regex. When a URL matching the regex is requested, the specified response is
served.</p>
<p>
Anchors provide an alternative to specifying the response in the URL. Instead, you attach
a response to a pre-configured anchor point, specified with a regex. When a URL
matching the regex is requested, the specified response is served.
</p>
<pre class="terminal">./pathod -a "/foo=200"</pre>
<p>Here, "/foo" is the regex specifying the anchor path, and the part after
the "=" is a response specifier.</p>
<p>
Here, "/foo" is the regex specifying the anchor path, and the part after the "=" is a
response specifier.
</p>
</section>
@ -87,14 +97,13 @@ the "=" is a response specifier.</p>
<h1>File Access</h1>
</div>
<p>There are two operators in the <a href="/docs/language">language</a> that
load contents from file - the <b>+</b> operator to load an entire request
specification from file, and the <b>&gt;</b> value specifier. In pathod, both
of these operators are restricted to a directory specified at startup, or
disabled if no directory is specified:</p>
<p>
There are two operators in the <a href="/docs/language">language</a> that load
contents from file - the <b>+</b> operator to load an entire request specification
from file, and the <b>&gt;</b> value specifier. In pathod, both of these operators
are restricted to a directory specified at startup, or disabled if no directory
is specified:</p>
<pre class="terminal">./pathod -d ~/staticdir"</pre>
</section>
@ -103,15 +112,16 @@ disabled if no directory is specified:</p>
<h1>Internal Error Responses</h1>
</div>
<p>Pathod uses the non-standard 800 response code to indicate internal
errors, to distinguish them from crafted responses. For example, a request
to:</p>
<p>
Pathod uses the non-standard 800 response code to indicate internal errors, to distinguish
them from crafted responses. For example, a request to:
</p>
<pre class="example">http://localhost:9999/p/foo</pre>
<p>... will return an 800 response because "foo" is not a valid page
specifier.</p>
<p>
... will return an 800 response because "foo" is not a valid page specifier.
</p>
</section>
@ -120,9 +130,10 @@ disabled if no directory is specified:</p>
<h1>API</h1>
</div>
<p>pathod exposes a simple API, intended to make it possible to drive and
inspect the daemon remotely for use in unit testing and the like. </p>
<p>
pathod exposes a simple API, intended to make it possible to drive and inspect the daemon
remotely for use in unit testing and the like.
</p>
<table class="table table-bordered">
<tbody>
@ -147,18 +158,16 @@ disabled if no directory is specified:</p>
/api/log
</td>
<td>
Returns the current log buffer. At the moment the buffer size is 500 entries -
when the log grows larger than this, older entries are discarded. The returned
Returns the current log buffer. At the moment the buffer size is 500 entries - when the
log grows larger than this, older entries are discarded. The returned
data is a JSON dictionary, with the form:
<pre>{ 'log': [ ENTRIES ] } </pre>
You can preview the JSON data returned for a log entry through the built-in web
interface.
You can preview the JSON data returned for a log entry through the built-in web interface.
</td>
</tr>
</tbody>
</table>
</section>
{% endblock %}

View File

@ -1,52 +1,50 @@
{% extends "docframe.html" %}
{% block body %}
{% extends "docframe.html" %} {% block body %}
<div class="page-header">
<h1>
libpathod.test
<small>Using pathod and pathoc in your unit tests.</small>
<small>Using libpathod in unit tests.</small>
</h1>
</div>
<div class="row">
<div class="span6">
<p> The <b>libpathod.test</b> module is a light, flexible testing layer
for HTTP clients. It works by firing up a Pathod instance in a separate
thread, letting you use Pathod's full abilities to generate responses,
and then query Pathod's internal logs to establish what happened. All
the mechanics of startup, shutdown, finding free ports and so forth are
taken care of for you. </p>
<p>The <b>libpathod.test</b> module is a light, flexible testing layer for HTTP clients.
It works by firing up a Pathod instance in a separate thread, letting you use Pathod's
full abilities to generate responses, and then query Pathod's internal logs to establish
what happened. All the mechanics of startup, shutdown, finding free ports and so forth
are taken care of for you.
</p>
<p>The canonical docs can be accessed using pydoc: </p>
<pre class="terminal">pydoc libpathod.test</pre>
<p> The remainder of this page demonstrates some common interaction
patterns using <a
href="http://nose.readthedocs.org/en/latest/">nose</a>. These examples
are also applicable with only minor modification to most commonly used
Python testing engines.</p>
<p>
The remainder of this page demonstrates some common interaction patterns using
<a
href="http://nose.readthedocs.org/en/latest/">nose</a>. These examples are also applicable with only minor modification to most
commonly used Python testing engines.
</p>
</div>
<div class="span6">
<section>
<div class="page-header">
<h1>Context Manager</h1>
</div>
{% include "examples_context.html" %}
</div>
</div>
</section>
<div class="row">
<div class="span6">
<section>
<div class="page-header">
<h1>One instance per test</h1>
</div>
{% include "examples_setup.html" %}
</div>
<div class="span6">
</section>
<section>
<div class="page-header">
<h1>One instance per suite</h1>
</div>
{% include "examples_setupall.html" %}
</div>
</div>
</section>
{% endblock %}

View File

@ -1,28 +1,19 @@
{% extends "frame.html" %}
{% block body %}
{% extends "frame.html" %} {% block body %}
<section>
<div class="page-header">
<h1>
pip
</h1>
<h1>pip</h1>
</div>
<p>The easiest way to install pathod is to use pip:</p>
<pre>pip install pathod</pre>
<p> This will automatically pull in all the dependencies, and you should be
good to go.</p>
<p>This will automatically pull in all the dependencies, and you should be good to go.</p>
</section>
<section>
<div class="page-header">
<h1>
github
</h1>
<h1>github</h1>
</div>
<p>You can find the project source on GitHub:</p>
@ -31,23 +22,16 @@
<a class="btn btn-primary btn-large" href="https://github.com/mitmproxy/pathod">github.com/mitmproxy/pathod</a>
</div>
<p>Please also use the <a
href="https://github.com/mitmproxy/pathod/issues">github issue tracker</a> to
report bugs. </p>
<p>Please also use the <a href="https://github.com/mitmproxy/pathod/issues">github issue tracker</a> to report bugs.</p>
</section>
<section>
<div class="page-header">
<h1>
tarball
</h1>
<h1>tarball</h1>
</div>
<div style="margin-top: 20px; margin-bottom: 20px">
<a class="btn btn-primary btn-large" href="https://github.com/downloads/mitmproxy/pathod/pathod-{{version}}.tar.gz">pathod-{{version}}.tar.gz</a>
</div>
</section>
{% endblock %}

View File

@ -1,6 +1,7 @@
<div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">from</span> <span class="nn">libpathod</span> <span class="kn">import</span> <span class="n">test</span>
<span class="k">def</span> <span class="nf">test_simple</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Testing the requests module with</span>

View File

@ -1,12 +1,15 @@
<div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">from</span> <span class="nn">libpathod</span> <span class="kn">import</span> <span class="n">test</span>
<span class="k">class</span> <span class="nc">Test</span><span class="p">:</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Testing the requests module with</span>
<span class="sd"> a pathod instance started for</span>
<span class="sd"> each test.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">setUp</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">d</span> <span class="o">=</span> <span class="n">test</span><span class="o">.</span><span class="n">Daemon</span><span class="p">()</span>

View File

@ -1,7 +1,9 @@
<div class="highlight"><pre><span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">from</span> <span class="nn">libpathod</span> <span class="kn">import</span> <span class="n">test</span>
<span class="k">class</span> <span class="nc">Test</span><span class="p">:</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Testing the requests module with</span>
<span class="sd"> a single pathod instance started</span>

View File

@ -1,9 +1,7 @@
{% extends "layout.html" %}
{% block content %}
{% extends "layout.html" %} {% block content %}
<div class="row">
<div class="span12">
{% block body %}
{% endblock %}
{% block body %} {% endblock %}
</div>
</div>
{% endblock %}

View File

@ -1,7 +1,4 @@
{% extends "frame.html" %}
{% block body %}
{% extends "frame.html" %} {% block body %}
<div class="masthead">
<div class="container">
<h1>pathod: pathological HTTP</h1>
@ -12,7 +9,6 @@
</div>
</div>
<div class="row">
<div class="span6">
<div>
@ -21,11 +17,10 @@
<p>A pathological web daemon.</p>
{% include "response_previewform.html" %}
<br>
</div>
</div>
</div>
</div>
<div class="span6">
<div>
<h2><a href="/docs/pathoc">pathoc</a></h2>
@ -33,7 +28,6 @@
<p>A perverse HTTP client.</p>
{% include "request_previewform.html" %}
</div>
</div>
</div>
@ -48,22 +42,19 @@
<h2>pip</h2>
<pre>pip install pathod</pre>
</div>
</div>
</div>
</div>
<div class="span6">
<div>
<h2>source</h2>
<ul>
<li>Current release: <a href="http://mitmproxy.org/download/pathod-{{version}}.tar.gz">pathod {{version}}</a></li>
<li>GitHub: <a href="https://github.com/mitmproxy/pathod">github.com/mitmproxy/pathod</a></li>
</li>
</ul>
</div>
</div>
</div>
</section>
{% endblock %}

View File

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>pathod</title>
@ -26,7 +27,6 @@
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
@ -51,8 +51,7 @@
</div>
<div class="container">
{% block content %}
{% endblock %}
{% block content %} {% endblock %}
<hr>
<footer>
<span>&copy; Aldo Cortesi 2015</span>
@ -62,12 +61,12 @@
</body>
<script>
$(function() {
$.localScroll(
{
$.localScroll({
duration: 300,
offset: {top: -45}
offset: {
top: -45
}
);
});
});
</script>
</html>

View File

@ -1,7 +1,8 @@
<div class="highlight"><pre><span class="c">#!/usr/bin/env python</span>
<span class="kn">from</span> <span class="nn">libpathod</span> <span class="kn">import</span> <span class="n">pathoc</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">pathoc</span><span class="o">.</span><span class="n">Pathoc</span><span class="p">(</span><span class="s">&quot;google.com&quot;</span><span class="p">,</span> <span class="mi">80</span><span class="p">)</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">pathoc</span><span class="o">.</span><span class="n">Pathoc</span><span class="p">((</span><span class="s">&quot;google.com&quot;</span><span class="p">,</span> <span class="mi">80</span><span class="p">))</span>
<span class="n">p</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="k">print</span> <span class="n">p</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">&quot;get:/&quot;</span><span class="p">)</span>
<span class="k">print</span> <span class="n">p</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">&quot;get:/foo&quot;</span><span class="p">)</span>
</pre></div>

View File

@ -1,8 +1,8 @@
{% extends "frame.html" %}
{% block body %}
{% extends "frame.html" %} {% block body %}
<form style="float: right" method="POST" action="/log/clear">
<button type="submit" class="btn">clear</button>
</form>
<h1>Logs</h1>
<hr>
@ -29,4 +29,3 @@
</tbody>
</table>
{% endblock %}

View File

@ -1,10 +1,8 @@
{% extends "frame.html" %}
{% block body %}
{% extends "frame.html" %} {% block body %}
<h2>Log entry {{ lid }}</h2>
<hr>
<pre>
{{ alog }}
</pre>
{% endblock %}

View File

@ -1,6 +1,4 @@
{% extends "frame.html" %}
{% block body %}
{% extends "frame.html" %} {% block body %}
<div class="page-header">
<h1>pathoc preview</h1>
</div>
@ -43,8 +41,4 @@
<p>Note: pauses are skipped when generating previews!</p>
</div>
</div>
{% endif %}
{% endblock %}
{% endif %} {% endblock %}

View File

@ -1,20 +1,14 @@
<form style="margin-bottom: 0" class="form-inline" method="GET" action="/request_preview">
<input
style="width: 18em"
id="spec"
name="spec"
class="input-medium"
value="{{spec}}"
placeholder="method:path:[features]"
>
<input style="width: 18em" id="spec" name="spec" class="input-medium" value="{{spec}}"
placeholder="method:path:[features]">
<input type="submit" class="btn" value="preview">
</form>
<a class="innerlink" data-toggle="collapse" data-target="#requestexamples">examples</a>
<div id="requestexamples" class="collapse">
<p>Check out the <a href="/docs/language">complete language docs</a>. Here
are some examples to get you started:</p>
<p>Check out the <a href="/docs/language">complete language docs</a>. Here are some examples
to get you started:</p>
<table class="table table-bordered">
<tbody>
@ -39,7 +33,9 @@
<td>Drop the connection randomly</td>
</tr>
<tr>
<td><a href="/request_preview?spec="></a></td>
<td>
<a href="/request_preview?spec="></a>
</td>
<td></td>
</tr>
<tr>

View File

@ -1,6 +1,4 @@
{% extends "frame.html" %}
{% block body %}
{% extends "frame.html" %} {% block body %}
<div class="page-header">
<h1>pathod preview</h1>
</div>
@ -43,6 +41,4 @@
<p>Note: pauses are skipped when generating previews!</p>
</div>
</div>
{% endif %}
{% endblock %}
{% endif %} {% endblock %}

View File

@ -1,23 +1,15 @@
<form style="margin-bottom: 0" class="form-inline" method="GET" action="/response_preview">
<input
style="width: 18em"
id="spec"
name="spec"
class="input-medium"
value="{{spec}}"
placeholder="code:[features]"
>
<input type="submit" class="btn" value="preview">
{% if not nocraft %}
<a href="#" id="submitspec" class="btn">go</a>
{% endif %}
<input style="width: 18em" id="spec" name="spec" class="input-medium" value="{{spec}}"
placeholder="code:[features]">
<input type="submit" class="btn" value="preview"> {% if not nocraft %}
<a href="#" id="submitspec" class="btn">go</a> {% endif %}
</form>
<a class="innerlink" data-toggle="collapse" data-target="#responseexamples">examples</a>
<div id="responseexamples" class="collapse">
<p>Check out the <a href="/docs/language">complete language docs</a>. Here
are some examples to get you started:</p>
<p>Check out the <a href="/docs/language">complete language docs</a>. Here are some examples
to get you started:</p>
<table class="table table-bordered">
<tbody>
@ -35,8 +27,8 @@
</tr>
<tr>
<td><a href="/response_preview?spec=200:b@100">200:b@100</a></td>
<td>100 random bytes as the body. A Content-Lenght header is
added, so the disconnect is no longer needed.</td>
<td>100 random bytes as the body. A Content-Lenght header is added, so the
disconnect is no longer needed.</td>
</tr>
<tr>
<td><a href='/response_preview?spec=200:b@100:h"Server"="&apos;;drop table servers;"'>200:b@100:h"Etag"="';drop table servers;"</a></td>
@ -66,18 +58,20 @@
<td>
<a href="/response_preview?spec=200:b@100:h@1k,ascii_letters='foo'">200:b@100:h@1k,ascii_letters='foo'</a>
</td>
<td>100 ASCII bytes as the body, randomly generated 100k header name, with the value 'foo'.</td>
<td>100 ASCII bytes as the body, randomly generated 100k header name, with
the value 'foo'.</td>
</tr>
</tbody>
</table>
</div>
{% if not nocraft %}
<script>
$(function() {
{% if not nocraft %}
$("#submitspec").click(function() {
document.location = "{{craftanchor}}" + $("#spec").val()
});
{% endif %}
});
</script>
{% endif %}