diff --git a/.gitignore b/.gitignore index c88c25ceb..4c8c70a23 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ MANIFEST netlib venv .idea/ -pathod.egg-info/ \ No newline at end of file +pathod.egg-info/ diff --git a/libpathod/templates/about.html b/libpathod/templates/about.html index 9a695a6a8..340dc386a 100644 --- a/libpathod/templates/about.html +++ b/libpathod/templates/about.html @@ -1,30 +1,22 @@ -{% extends "frame.html" %} -{% block body %} - - +{% extends "frame.html" %} {% block body %}
- -
-
-
-

pathod is developed by Aldo - Cortesi.

-
+ +
+
+
+

pathod is developed by Aldo Cortesi.

+
-
- +
+ +
-
- - {% endblock %} diff --git a/libpathod/templates/docframe.html b/libpathod/templates/docframe.html index f780f3798..4cbdeebce 100644 --- a/libpathod/templates/docframe.html +++ b/libpathod/templates/docframe.html @@ -1,26 +1,26 @@ {% extends "layout.html" %} {% macro subs(s) %} -{% if subsection == s %} class="active" {% endif %} + {% if subsection == s %} + class="active" + {% endif %} {% endmacro %} - -{% block content %} +{% block content %}
- {% block body %} - {% endblock %} + {% block body %} {% endblock %}
-{% endblock %} +{% endblock %} diff --git a/libpathod/templates/docs_lang.html b/libpathod/templates/docs_lang.html index ce778dc97..e3195939d 100644 --- a/libpathod/templates/docs_lang.html +++ b/libpathod/templates/docs_lang.html @@ -1,17 +1,15 @@ -{% extends "docframe.html" %} -{% block body %} - +{% extends "docframe.html" %} {% block body %}
@@ -28,151 +26,171 @@
- -

OFFSET

+ +

OFFSET

-

Offsets are calculated relative to the base message, before any - injections or other transforms are applied. They have 3 flavors:

+

+ Offsets are calculated relative to the base message, before any injections or other transforms + are applied. They have 3 flavors: +

- + - -

VALUE

+ +

VALUE

-

Literals

+

Literals

-

Literal values are specified as a quoted strings:

+

Literal values are specified as a quoted strings:

-
"foo"
+
"foo"
-

Either single or double quotes are accepted, and quotes can be escaped with - backslashes within the string:

+

+ Either single or double quotes are accepted, and quotes can be escaped with backslashes + within the string: +

-
'fo\'o'
+
'fo\'o'
-

Literal values can contain Python-style backslash escape sequences:

+

Literal values can contain Python-style backslash escape sequences:

-
'foo\r\nbar'
+
'foo\r\nbar'
+ +

Files

+ +

+ 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: +

+ +
pathod -d ~/myassets
+ +

+ All paths are relative paths under this directory. File loads are indicated by starting + the value specifier with the left angle bracket: +

+ +
<my/path
+ +

The path value can also be a quoted string, with the same syntax as literals:

+ +
<"my/path"
-

Files

+

Generated values

-

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:

+

+ 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". +

-
pathod -d ~/myassets
+

Here's a value specifier for generating 100 bytes: -

All paths are relative paths under this directory. File loads are indicated by - starting the value specifier with the left angle bracket: +

@100
+

-
<my/path

+

+ You can use standard suffixes to indicate larger values. Here, for instance, is a specifier + for generating 100 megabytes: +

-

The path value can also be a quoted string, with the same syntax as literals:

+
@100m
-
<"my/path"
+

+ 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: +

+ + + + + + + + + + + + + + + + + + + + + + + +
b1024**0 (bytes)
k1024**1 (kilobytes)
m1024**2 (megabytes)
g1024**3 (gigabytes)
t1024**4 (terabytes)
-

Generated values

+

+ Data types are separated from the size specification by a comma. This specification generates + 100mb of ASCII: +

-

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".

+
@100m,ascii
-

Here's a value specifier for generating 100 bytes: +

Supported data types are:

-
@100

- -

You can use standard suffixes to indicate larger values. Here, for instance, is - a specifier for generating 100 megabytes:

- -
@100m
- -

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:

- - - - - - - - - - - - - - - - - - - - -
b 1024**0 (bytes)
k 1024**1 (kilobytes)
m 1024**2 (megabytes)
g 1024**3 (gigabytes)
t 1024**4 (terabytes)
- -

Data types are separated from the size specification by a comma. This - specification generates 100mb of ASCII:

- -
@100m,ascii
- -

Supported data types are:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
asciiAll ASCII characters
ascii_lettersA-Za-z
ascii_lowercasea-z
ascii_uppercaseA-Z
bytesAll 256 byte values
digits0-9
hexdigits0-f
octdigits0-7
punctuation -
!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~
-
whitespace -
\t\n\x0b\x0c\r and space
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
asciiAll ASCII characters
ascii_lettersA-Za-z
ascii_lowercasea-z
ascii_uppercaseA-Z
bytesAll 256 byte values
digits0-9
hexdigits0-f
octdigits0-7
punctuation +
!"#$%&\'()*+,-./:;
+                        <=>?@[\\]^_`{|}~
+
whitespace +
\t\n\x0b\x0c\r and space
+
- {% endblock %} diff --git a/libpathod/templates/docs_lang_websockets.html b/libpathod/templates/docs_lang_websockets.html index 32bd71f97..682f4cc89 100644 --- a/libpathod/templates/docs_lang_websockets.html +++ b/libpathod/templates/docs_lang_websockets.html @@ -1,13 +1,13 @@ -
wf:[colon-separated list of features]

+
wf:[colon-separated list of features]
+

- + @@ -15,8 +15,8 @@ @@ -71,16 +70,15 @@ diff --git a/libpathod/templates/docs_libpathod.html b/libpathod/templates/docs_libpathod.html index 3e18c1d90..72b24e832 100644 --- a/libpathod/templates/docs_libpathod.html +++ b/libpathod/templates/docs_libpathod.html @@ -1,8 +1,6 @@ -{% extends "docframe.html" %} -{% block body %} - +{% extends "docframe.html" %} {% block body %}
bVALUE - 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.
cINTEGER - Set the op code. This can either be an integer from 0-15, or be - one of the following opcode names: text (the default), + Set the op code. This can either be an integer from 0-15, or be one of the following opcode + names: text (the default), continue, binary, close, ping, pong. @@ -47,17 +47,16 @@
kVALUE - Set the masking key. The resulting value must be exactly 4 - bytes long. The special form knone 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 + knone specifies that no key should be set, even + if the mask bit is on.
lINTEGER - 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.
pOFFSET,SECONDS - 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.
rVALUE - 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.
- +
/api/clear_log @@ -147,18 +158,16 @@ disabled if no directory is specified:

/api/log
- 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:
{ 'log': [ ENTRIES ] } 
- 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.
- {% endblock %} diff --git a/libpathod/templates/docs_test.html b/libpathod/templates/docs_test.html index 25205d41e..5db45f3fe 100644 --- a/libpathod/templates/docs_test.html +++ b/libpathod/templates/docs_test.html @@ -1,52 +1,50 @@ -{% extends "docframe.html" %} -{% block body %} +{% extends "docframe.html" %} {% block body %} -
-
+

The libpathod.test 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. +

-

The libpathod.test 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.

+

The canonical docs can be accessed using pydoc:

-

The canonical docs can be accessed using pydoc:

+
pydoc libpathod.test
-
pydoc libpathod.test
- -

The remainder of this page demonstrates some common interaction - patterns using nose. These examples - are also applicable with only minor modification to most commonly used - Python testing engines.

+

+ The remainder of this page demonstrates some common interaction patterns using + nose. These examples are also applicable with only minor modification to most + commonly used Python testing engines. +

+
+ -
-

Context Manager

- {% include "examples_context.html" %} + {% include "examples_context.html" %} +
+ +
+ -
-
-
-

One instance per test

+ {% include "examples_setup.html" %} + - {% include "examples_setup.html" %} +
+ -
-

One instance per suite

- {% include "examples_setupall.html" %} -
-
- - -{% endblock %} + {% include "examples_setupall.html" %} + +{% endblock %} diff --git a/libpathod/templates/download.html b/libpathod/templates/download.html index 2f6ed2873..02ae9d418 100644 --- a/libpathod/templates/download.html +++ b/libpathod/templates/download.html @@ -1,53 +1,37 @@ -{% extends "frame.html" %} -{% block body %} - +{% extends "frame.html" %} {% block body %}

The easiest way to install pathod is to use pip:

pip install pathod
-

This will automatically pull in all the dependencies, and you should be - good to go.

- +

This will automatically pull in all the dependencies, and you should be good to go.

-
-

You can find the project source on GitHub:

+

You can find the project source on GitHub:

- github.com/mitmproxy/pathod + github.com/mitmproxy/pathod
-

Please also use the github issue tracker to - report bugs.

+

Please also use the github issue tracker to report bugs.

-
- pathod-{{version}}.tar.gz + pathod-{{version}}.tar.gz
- - {% endblock %} diff --git a/libpathod/templates/examples_context.html b/libpathod/templates/examples_context.html index 39146d37a..afb3bd481 100644 --- a/libpathod/templates/examples_context.html +++ b/libpathod/templates/examples_context.html @@ -1,6 +1,7 @@
import requests
 from libpathod import test
 
+
 def test_simple():
     """
         Testing the requests module with
diff --git a/libpathod/templates/examples_setup.html b/libpathod/templates/examples_setup.html
index b80ad3796..c2da1cd15 100644
--- a/libpathod/templates/examples_setup.html
+++ b/libpathod/templates/examples_setup.html
@@ -1,12 +1,15 @@
 
import requests
 from libpathod import test
 
+
 class Test:
+
     """
         Testing the requests module with
         a pathod instance started for
         each test.
     """
+
     def setUp(self):
         self.d = test.Daemon()
 
diff --git a/libpathod/templates/examples_setupall.html b/libpathod/templates/examples_setupall.html
index b7f799753..629d11e0e 100644
--- a/libpathod/templates/examples_setupall.html
+++ b/libpathod/templates/examples_setupall.html
@@ -1,10 +1,12 @@
 
import requests
 from libpathod import test
 
+
 class Test:
+
     """
-        Testing the requests module with 
-        a single pathod instance started 
+        Testing the requests module with
+        a single pathod instance started
         for the test suite.
     """
     @classmethod
diff --git a/libpathod/templates/frame.html b/libpathod/templates/frame.html
index b5c5c67c8..4223458d5 100644
--- a/libpathod/templates/frame.html
+++ b/libpathod/templates/frame.html
@@ -1,9 +1,7 @@
-{% extends "layout.html" %}
-{% block content %}  
+{% extends "layout.html" %} {% block content %}
 
- {% block body %} - {% endblock %} + {% block body %} {% endblock %}
-{% endblock %} +{% endblock %} diff --git a/libpathod/templates/index.html b/libpathod/templates/index.html index 06a42dec5..a85a40409 100644 --- a/libpathod/templates/index.html +++ b/libpathod/templates/index.html @@ -1,7 +1,4 @@ -{% extends "frame.html" %} -{% block body %} - - +{% extends "frame.html" %} {% block body %}

pathod: pathological HTTP

@@ -12,58 +9,52 @@
-
-

pathod

+

pathod

A pathological web daemon.

{% include "response_previewform.html" %} -
-
+
-

pathoc

+

pathoc

A perverse HTTP client.

{% include "request_previewform.html" %} -
- -
-
-
-

pip

+ +
+
+
+

pip

-
pip install pathod
+
pip install pathod
+
+
+
+
+

source

+ + +
-
-
-

source

- -
-
-
- - {% endblock %} diff --git a/libpathod/templates/layout.html b/libpathod/templates/layout.html index 5278e5aa4..b405ec34f 100644 --- a/libpathod/templates/layout.html +++ b/libpathod/templates/layout.html @@ -1,6 +1,7 @@ - + + pathod @@ -14,60 +15,58 @@ - - - + + {% if syntaxerror %} -
-
- Error: -
-
-

{{ syntaxerror }}

-
{{ marked }}
-
+
+
+ Error:
+
+

{{ syntaxerror }}

+
{{ marked }}
+
+
{% elif error %} -
-
- Error: -
-
-

{{ error }}

-
+
+
+ Error:
+
+

{{ error }}

+
+
{% else %} -
-
- Request: -
-
-
{{ output }}
-

Note: pauses are skipped when generating previews!

-
+
+
+ Request:
-{% endif %} - -{% endblock %} - - +
+
{{ output }}
+

Note: pauses are skipped when generating previews!

+
+
+{% endif %} {% endblock %} diff --git a/libpathod/templates/request_previewform.html b/libpathod/templates/request_previewform.html index d30837359..0c6755de4 100644 --- a/libpathod/templates/request_previewform.html +++ b/libpathod/templates/request_previewform.html @@ -1,23 +1,17 @@
- +
examples
-

Check out the complete language docs. Here - are some examples to get you started:

+

Check out the complete language docs. Here are some examples + to get you started:

- + @@ -39,7 +33,9 @@ - + diff --git a/libpathod/templates/response_preview.html b/libpathod/templates/response_preview.html index ce6a40988..bbce6d6ca 100644 --- a/libpathod/templates/response_preview.html +++ b/libpathod/templates/response_preview.html @@ -1,6 +1,4 @@ -{% extends "frame.html" %} -{% block body %} - +{% extends "frame.html" %} {% block body %} @@ -15,34 +13,32 @@ {% if syntaxerror %} -
-
- Error: -
-
-

{{ syntaxerror }}

-
{{ marked }}
-
+
+
+ Error:
+
+

{{ syntaxerror }}

+
{{ marked }}
+
+
{% elif error %} -
-
- Error: -
-
-

{{ error }}

-
+
+
+ Error:
+
+

{{ error }}

+
+
{% else %} -
-
- Response: -
-
-
{{ output }}
-

Note: pauses are skipped when generating previews!

-
+
+
+ Response:
-{% endif %} - -{% endblock %} +
+
{{ output }}
+

Note: pauses are skipped when generating previews!

+
+
+{% endif %} {% endblock %} diff --git a/libpathod/templates/response_previewform.html b/libpathod/templates/response_previewform.html index d91a2a675..51e178142 100644 --- a/libpathod/templates/response_previewform.html +++ b/libpathod/templates/response_previewform.html @@ -1,26 +1,18 @@
- - - {% if not nocraft %} - go - {% endif %} + + {% if not nocraft %} + go {% endif %} examples
-

Check out the complete language docs. Here - are some examples to get you started:

+

Check out the complete language docs. Here are some examples + to get you started:

get:/ Get path /Drop the connection randomly
+ +
- + @@ -35,8 +27,8 @@ - + @@ -66,18 +58,20 @@ - +
200 A basic HTTP 200 response.
200:b@100100 random bytes as the body. A Content-Lenght header is - added, so the disconnect is no longer needed.100 random bytes as the body. A Content-Lenght header is added, so the + disconnect is no longer needed.
200:b@100:h"Etag"="';drop table servers;" 200:b@100:h@1k,ascii_letters='foo' 100 ASCII bytes as the body, randomly generated 100k header name, with the value 'foo'.100 ASCII bytes as the body, randomly generated 100k header name, with + the value 'foo'.
+{% if not nocraft %} +{% endif %}