A fork of pappy proxy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1936 lines
119 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>pappyproxy package &mdash; Pappy Proxy 0.2.11 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.2.11',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Pappy Proxy 0.2.11 documentation" href="index.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Pappy Proxy 0.2.11 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="pappyproxy-package">
<h1>pappyproxy package<a class="headerlink" href="#pappyproxy-package" title="Permalink to this headline"></a></h1>
<div class="section" id="subpackages">
<h2>Subpackages<a class="headerlink" href="#subpackages" title="Permalink to this headline"></a></h2>
<div class="toctree-wrapper compound">
<ul class="simple">
</ul>
</div>
</div>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-pappyproxy.comm">
<span id="pappyproxy-comm-module"></span><h2>pappyproxy.comm module<a class="headerlink" href="#module-pappyproxy.comm" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-pappyproxy.config">
<span id="pappyproxy-config-module"></span><h2>pappyproxy.config module<a class="headerlink" href="#module-pappyproxy.config" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="pappyproxy.config.PappyConfig">
<em class="property">class </em><code class="descclassname">pappyproxy.config.</code><code class="descname">PappyConfig</code><a class="headerlink" href="#pappyproxy.config.PappyConfig" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>The configuration settings for the proxy. To access the config object for the
current session (eg from plugins) use <code class="docutils literal"><span class="pre">pappyproxy.pappy.session.config</span></code>.</p>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.cert_dir">
<code class="descname">cert_dir</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.cert_dir" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The location of the CA certs that Pappy will use. This can be configured in the
<code class="docutils literal"><span class="pre">config.json</span></code> file for a project.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">{DATADIR}/certs</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.pappy_dir">
<code class="descname">pappy_dir</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.pappy_dir" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The file where pappy&#8217;s scripts are located. Don&#8217;t write anything here, and you
probably don&#8217;t need to write anything here. Use DATA_DIR instead.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body">Wherever the scripts are installed</td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.data_dir">
<code class="descname">data_dir</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.data_dir" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The data directory. This is where files that have to be read by Pappy every time
it&#8217;s run are put. For example, plugins are stored in <code class="docutils literal"><span class="pre">{DATADIR}/plugins</span></code> and
certs are by default stored in <code class="docutils literal"><span class="pre">{DATADIR}/certs</span></code>. This defaults to <code class="docutils literal"><span class="pre">~/.pappy</span></code>
and isn&#8217;t configurable right now.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">~/.pappy</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.datafile">
<code class="descname">datafile</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.datafile" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The location of the CA certs that Pappy will use. This can be configured in the
<code class="docutils literal"><span class="pre">config.json</span></code> file for a project.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">data.db</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.debug_dir">
<code class="descname">debug_dir</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.debug_dir" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The directory to write debug output to. Don&#8217;t put this outside the project folder
since it writes all the request data to this directory. You probably won&#8217;t need
to use this. Configured in the <code class="docutils literal"><span class="pre">config.json</span></code> file for the project.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body">None</td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.listeners">
<code class="descname">listeners</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.listeners" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The list of active listeners. It is a list of tuples of the format (port, interface)
Not modifiable after startup. Configured in the <code class="docutils literal"><span class="pre">config.json</span></code> file for the project.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">[(8000,</span> <span class="pre">'127.0.0.1')]</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.socks_proxy">
<code class="descname">socks_proxy</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.socks_proxy" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Details for a SOCKS proxy. It is a dict with the following key/values:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>host: The SOCKS proxy host
port: The proxy port
username: Username (optional)
password: Password (optional)
</pre></div>
</div>
<p>If null, no proxy will be used.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">null</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.http_proxy">
<code class="descname">http_proxy</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.http_proxy" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Details for an upstream HTTP proxy. It is a dict with the following key/values:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>host: The proxy host
port: The proxy port
username: Username (optional)
password: Password (optional)
</pre></div>
</div>
<p>If null, no proxy will be used.</p>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.plugin_dirs">
<code class="descname">plugin_dirs</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.plugin_dirs" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>List of directories that plugins are loaded from. Not modifiable.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">['{DATA_DIR}/plugins',</span> <span class="pre">'{PAPPY_DIR}/plugins']</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.save_history">
<code class="descname">save_history</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.save_history" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Whether command history should be saved to a file/loaded at startup.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body">True</td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.config_dict">
<code class="descname">config_dict</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.config_dict" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The dictionary read from config.json. When writing plugins, use this to load
configuration options for your plugin.</p>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.global_config_dict">
<code class="descname">global_config_dict</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.global_config_dict" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The dictionary from ~/.pappy/global_config.json. It contains settings for
Pappy that are specific to the current computer. Avoid putting settings here,
especially if it involves specific projects.</p>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.archive">
<code class="descname">archive</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.archive" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Project archive compressed as a <code class="docutils literal"><span class="pre">tar.bz2</span></code> archive if libraries available on the system,
otherwise falls back to zip archive.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">project.archive</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.crypt_dir">
<code class="descname">crypt_dir</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.crypt_dir" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Temporary working directory to unpack an encrypted project archive. Directory
will contain copies of normal startup files, e.g. conifg.json, cmdhistory, etc.
On exiting pappy, entire directory will be compressed into an archive and encrypted.
Compressed as a tar.bz2 archive if libraries available on the system,
otherwise falls back to zip.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">crypt</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.crypt_file">
<code class="descname">crypt_file</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.crypt_file" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Encrypted archive of the temporary working directory <code class="docutils literal"><span class="pre">crypt_dir</span></code>. Compressed as a
tar.bz2 archive if libraries available on the system, otherwise falls back to zip.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body"><code class="docutils literal"><span class="pre">project.crypt</span></code></td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.crypt_session">
<code class="descname">crypt_session</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.crypt_session" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Boolean variable to determine whether pappy started in crypto mode</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body">False</td>
</tr>
</tbody>
</table>
<dl class="data">
<dt id="pappyproxy.config.PappyConfig.salt_len">
<code class="descname">salt_len</code><a class="headerlink" href="#pappyproxy.config.PappyConfig.salt_len" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>Length of the nonce-salt value appended to the end of <cite>crypt_file</cite></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Default:</th><td class="field-body">16</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.console">
<span id="pappyproxy-console-module"></span><h2>pappyproxy.console module<a class="headerlink" href="#module-pappyproxy.console" title="Permalink to this headline"></a></h2>
<p>Contains helpers for interacting with the console. Includes definition for the
class that is used to run the console.</p>
<dl class="class">
<dt id="pappyproxy.console.ProxyCmd">
<em class="property">class </em><code class="descclassname">pappyproxy.console.</code><code class="descname">ProxyCmd</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.console.ProxyCmd" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">cmd2.Cmd</span></code></p>
<p>An object representing the console interface. Provides methods to add
commands and aliases to the console.</p>
<dl class="method">
<dt id="pappyproxy.console.ProxyCmd.add_alias">
<code class="descname">add_alias</code><span class="sig-paren">(</span><em>command</em>, <em>alias</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.console.ProxyCmd.add_alias" title="Permalink to this definition"></a></dt>
<dd><p>Add an alias for a command.
ie add_alias(&#8220;foo&#8221;, &#8220;f&#8221;) will let you run the &#8216;foo&#8217; command with &#8216;f&#8217;</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.console.ProxyCmd.add_aliases">
<code class="descname">add_aliases</code><span class="sig-paren">(</span><em>alias_list</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.console.ProxyCmd.add_aliases" title="Permalink to this definition"></a></dt>
<dd><p>Pass in a list of tuples to add them all as aliases.
ie add_aliases([(&#8216;foo&#8217;, &#8216;f&#8217;), (&#8216;foo&#8217;, &#8216;fo&#8217;)]) will add &#8216;f&#8217; and &#8216;fo&#8217; as
aliases for &#8216;foo&#8217;</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.console.ProxyCmd.set_cmd">
<code class="descname">set_cmd</code><span class="sig-paren">(</span><em>command</em>, <em>func</em>, <em>autocomplete_func=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.console.ProxyCmd.set_cmd" title="Permalink to this definition"></a></dt>
<dd><p>Add a command to the console.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.console.ProxyCmd.set_cmds">
<code class="descname">set_cmds</code><span class="sig-paren">(</span><em>cmd_dict</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.console.ProxyCmd.set_cmds" title="Permalink to this definition"></a></dt>
<dd><p>Set multiple commands from a dictionary. Format is:
{&#8216;command&#8217;: (do_func, autocomplete_func)}
Use autocomplete_func=None for no autocomplete function</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.context">
<span id="pappyproxy-context-module"></span><h2>pappyproxy.context module<a class="headerlink" href="#module-pappyproxy.context" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="pappyproxy.context.Context">
<em class="property">class </em><code class="descclassname">pappyproxy.context.</code><code class="descname">Context</code><a class="headerlink" href="#pappyproxy.context.Context" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>A class representing a set of requests that pass a set of filters</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Variables:</th><td class="field-body"><ul class="first last simple">
<li><strong>active_filters</strong> (List of functions that takes one <a class="reference internal" href="#pappyproxy.http.Request" title="pappyproxy.http.Request"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.http.Request</span></code></a> and returns either true or false.) &#8211; Filters that are currently applied to the context</li>
<li><strong>active_requests</strong> &#8211; Requests which pass all the filters applied to the context</li>
<li><strong>inactive_requests</strong> &#8211; Requests which do not pass all the filters applied to the context</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pappyproxy.context.Context.add_filter">
<code class="descname">add_filter</code><span class="sig-paren">(</span><em>filt</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.context.Context.add_filter" title="Permalink to this definition"></a></dt>
<dd><p>Add a filter to the context. This will remove any requests that do not pass
the filter from the <code class="docutils literal"><span class="pre">active_requests</span></code> set.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filt</strong> (Function that takes one <a class="reference internal" href="#pappyproxy.http.Request" title="pappyproxy.http.Request"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.http.Request</span></code></a> and returns either true or false. (or a <a class="reference internal" href="#pappyproxy.context.Filter" title="pappyproxy.context.Filter"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.context.Filter</span></code></a>)) &#8211; The filter to add</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.context.Context.filter_up">
<code class="descname">filter_up</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.context.Context.filter_up" title="Permalink to this definition"></a></dt>
<dd><p>Removes the last filter that was applied to the context.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.context.Context.set_filters">
<code class="descname">set_filters</code><span class="sig-paren">(</span><em>filters</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.context.Context.set_filters" title="Permalink to this definition"></a></dt>
<dd><p>Set the list of filters for the context.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pappyproxy.context.Filter">
<em class="property">class </em><code class="descclassname">pappyproxy.context.</code><code class="descname">Filter</code><span class="sig-paren">(</span><em>filter_string</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.context.Filter" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>A class representing a filter. Its claim to fame is that you can use
<a class="reference internal" href="#pappyproxy.context.Filter.from_filter_string" title="pappyproxy.context.Filter.from_filter_string"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.context.Filter.from_filter_string()</span></code></a> to generate a
filter from a filter string.</p>
<dl class="staticmethod">
<dt id="pappyproxy.context.Filter.from_filter_string">
<em class="property">static </em><code class="descname">from_filter_string</code><span class="sig-paren">(</span><em>filter_string</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.context.Filter.from_filter_string" title="Permalink to this definition"></a></dt>
<dd><p>Create a filter from a filter string. If passed a list of arguments, they
will be used instead of parsing the string.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Deferred that returns a <a class="reference internal" href="#pappyproxy.context.Filter" title="pappyproxy.context.Filter"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.context.Filter</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.context.async_set_tag">
<code class="descclassname">pappyproxy.context.</code><code class="descname">async_set_tag</code><span class="sig-paren">(</span><em>tag</em>, <em>reqs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.context.async_set_tag" title="Permalink to this definition"></a></dt>
<dd><p>Remove the tag from every request then add the given requests to memory and
give them the tag. The async version.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>tag</strong> (<em>String</em>) &#8211; The tag to set</li>
<li><strong>reqs</strong> (<em>List of Requests</em>) &#8211; The requests to assign to the tag</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.context.set_tag">
<code class="descclassname">pappyproxy.context.</code><code class="descname">set_tag</code><span class="sig-paren">(</span><em>tag</em>, <em>reqs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.context.set_tag" title="Permalink to this definition"></a></dt>
<dd><p>Remove the tag from every request then add the given requests to memory and
give them the tag. The non-async version.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>tag</strong> (<em>String</em>) &#8211; The tag to set</li>
<li><strong>reqs</strong> (<em>List of Requests</em>) &#8211; The requests to assign to the tag</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.http">
<span id="pappyproxy-http-module"></span><h2>pappyproxy.http module<a class="headerlink" href="#module-pappyproxy.http" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="pappyproxy.http.HTTPMessage">
<em class="property">class </em><code class="descclassname">pappyproxy.http.</code><code class="descname">HTTPMessage</code><span class="sig-paren">(</span><em>full_message=None</em>, <em>update_content_length=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.HTTPMessage" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>A base class which represents an HTTP message. It is used to implement
both requests and responses</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Variables:</th><td class="field-body"><ul class="first last simple">
<li><strong>complete</strong> (<a class="reference internal" href="#pappyproxy.http.RepeatableDict" title="pappyproxy.http.RepeatableDict"><em>RepeatableDict</em></a>) &#8211; When loading data with
<a class="reference internal" href="#pappyproxy.http.HTTPMessage.add_line" title="pappyproxy.http.HTTPMessage.add_line"><code class="xref py py-func docutils literal"><span class="pre">add_line()</span></code></a> and
<a class="reference internal" href="#pappyproxy.http.HTTPMessage.add_data" title="pappyproxy.http.HTTPMessage.add_data"><code class="xref py py-func docutils literal"><span class="pre">add_data()</span></code></a>, returns whether the message
is complete</li>
<li><strong>headers</strong> &#8211; Headers of the message</li>
<li><strong>headers_complete</strong> &#8211; When creating the message with
<a class="reference internal" href="#pappyproxy.http.HTTPMessage.add_line" title="pappyproxy.http.HTTPMessage.add_line"><code class="xref py py-func docutils literal"><span class="pre">add_line()</span></code></a> and
<a class="reference internal" href="#pappyproxy.http.HTTPMessage.add_data" title="pappyproxy.http.HTTPMessage.add_data"><code class="xref py py-func docutils literal"><span class="pre">add_data()</span></code></a>, returns whether the headers
are complete</li>
<li><a class="reference internal" href="#pappyproxy.http.Request.start_line" title="pappyproxy.http.Request.start_line"><strong>start_line</strong></a> (<a class="reference external" href="https://docs.python.org/library/string.html#module-string" title="(in Python v2.7)"><em>string</em></a>) &#8211; The start line of the message</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pappyproxy.http.HTTPMessage.add_data">
<code class="descname">add_data</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.HTTPMessage.add_data" title="Permalink to this definition"></a></dt>
<dd><p>Used for building a message from a Twisted protocol.
Add data to the message. The data must conform to the content encoding
and transfer encoding given in the headers passed in to
<a class="reference internal" href="#pappyproxy.http.HTTPMessage.add_line" title="pappyproxy.http.HTTPMessage.add_line"><code class="xref py py-func docutils literal"><span class="pre">add_line()</span></code></a>. Can be any fragment of the data.
I do not suggest that you use this function ever.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<a class="reference external" href="https://docs.python.org/library/string.html#module-string" title="(in Python v2.7)"><em>string</em></a>) &#8211; The data to add</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.HTTPMessage.add_line">
<code class="descname">add_line</code><span class="sig-paren">(</span><em>line</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.HTTPMessage.add_line" title="Permalink to this definition"></a></dt>
<dd><p>Used for building a message from a Twisted protocol.
Add a line (for status line and headers). Lines must be added in order
and the first line must be the status line. The line should not contain
the trailing carriage return/newline. I do not suggest you use this for
anything.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>line</strong> (<a class="reference external" href="https://docs.python.org/library/string.html#module-string" title="(in Python v2.7)"><em>string</em></a>) &#8211; The line to add</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.HTTPMessage.body">
<code class="descname">body</code><a class="headerlink" href="#pappyproxy.http.HTTPMessage.body" title="Permalink to this definition"></a></dt>
<dd><p>The data portion of the message</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the data portion of the message</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Set the data of the response and update metadata</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.HTTPMessage.body_pretty">
<code class="descname">body_pretty</code><a class="headerlink" href="#pappyproxy.http.HTTPMessage.body_pretty" title="Permalink to this definition"></a></dt>
<dd><p>Same thing as <code class="xref py py-func docutils literal"><span class="pre">pappy.http.HTTPMessage.body()</span></code> but the output is
colorized for the terminal.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.HTTPMessage.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.HTTPMessage.clear" title="Permalink to this definition"></a></dt>
<dd><p>Resets all internal data and clears the message</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.HTTPMessage.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.HTTPMessage.copy" title="Permalink to this definition"></a></dt>
<dd><p>Returns a copy of the request</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#pappyproxy.http.Request" title="pappyproxy.http.Request">Request</a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.HTTPMessage.from_json">
<code class="descname">from_json</code><span class="sig-paren">(</span><em>json_string</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.HTTPMessage.from_json" title="Permalink to this definition"></a></dt>
<dd><p>Update the metadata of the message to match data from
<code class="xref py py-func docutils literal"><span class="pre">to_json()</span></code></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>json_string</strong> (<em>JSON data in a string</em>) &#8211; The JSON data to use</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.HTTPMessage.full_message">
<code class="descname">full_message</code><a class="headerlink" href="#pappyproxy.http.HTTPMessage.full_message" title="Permalink to this definition"></a></dt>
<dd><p>The full message including the start line, headers, and body</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.HTTPMessage.full_message_pretty">
<code class="descname">full_message_pretty</code><a class="headerlink" href="#pappyproxy.http.HTTPMessage.full_message_pretty" title="Permalink to this definition"></a></dt>
<dd><p>Same as <a class="reference internal" href="#pappyproxy.http.HTTPMessage.full_message" title="pappyproxy.http.HTTPMessage.full_message"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.http.HTTPMessage.full_message()</span></code></a> except the
output is colorized</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.HTTPMessage.headers_section">
<code class="descname">headers_section</code><a class="headerlink" href="#pappyproxy.http.HTTPMessage.headers_section" title="Permalink to this definition"></a></dt>
<dd><p>The raw text of the headers including the extra newline at the end.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the raw text of the headers including the extra newline at the end.</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.HTTPMessage.headers_section_pretty">
<code class="descname">headers_section_pretty</code><a class="headerlink" href="#pappyproxy.http.HTTPMessage.headers_section_pretty" title="Permalink to this definition"></a></dt>
<dd><p>Same thing as <a class="reference internal" href="#pappyproxy.http.HTTPMessage.headers_section" title="pappyproxy.http.HTTPMessage.headers_section"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.http.HTTPMessage.headers_section()</span></code></a> except
that the headers are colorized for terminal printing.</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.HTTPMessage.reserved_meta_keys">
<code class="descname">reserved_meta_keys</code><em class="property"> = ['full_message']</em><a class="headerlink" href="#pappyproxy.http.HTTPMessage.reserved_meta_keys" title="Permalink to this definition"></a></dt>
<dd><p>Internal class variable. Do not modify.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.HTTPMessage.to_json">
<code class="descname">to_json</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.HTTPMessage.to_json" title="Permalink to this definition"></a></dt>
<dd><p>Return a JSON encoding of the message that can be used by
<code class="xref py py-func docutils literal"><span class="pre">from_json()</span></code> to recreate the message.
The <code class="docutils literal"><span class="pre">full_message</span></code> portion is base64 encoded because json doesn&#8217;t play
nice with binary blobs.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pappyproxy.http.RepeatableDict">
<em class="property">class </em><code class="descclassname">pappyproxy.http.</code><code class="descname">RepeatableDict</code><span class="sig-paren">(</span><em>from_pairs=None</em>, <em>case_insensitive=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict" title="Permalink to this definition"></a></dt>
<dd><p>A dict that retains the order of items inserted and keeps track of
duplicate values. Can optionally treat keys as case insensitive.
Custom made for the proxy, so it has strange features</p>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.add_pairs">
<code class="descname">add_pairs</code><span class="sig-paren">(</span><em>pairs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.add_pairs" title="Permalink to this definition"></a></dt>
<dd><p>Add a list of pairs to the dictionary.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>pairs</strong> (<em>List of tuples of length 2</em>) &#8211; The list of key/value pairs to add</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.all_pairs">
<code class="descname">all_pairs</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.all_pairs" title="Permalink to this definition"></a></dt>
<dd><p>A list of all the key/value pairs stored in the dictionary</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.all_vals">
<code class="descname">all_vals</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.all_vals" title="Permalink to this definition"></a></dt>
<dd><p>Return all the values associated with a given key</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.append">
<code class="descname">append</code><span class="sig-paren">(</span><em>key</em>, <em>val</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.append" title="Permalink to this definition"></a></dt>
<dd><p>Append a pair to the end of the dictionary. Will add a duplicate if the key already exists.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.clear" title="Permalink to this definition"></a></dt>
<dd><p>Remove all key/value pairs from the dictionary</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.from_dict">
<code class="descname">from_dict</code><span class="sig-paren">(</span><em>d</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.from_dict" title="Permalink to this definition"></a></dt>
<dd><p>Set the RepeatableDict to contain the same items as a normal dictionary.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>d</strong> (<a class="reference external" href="https://docs.python.org/library/stdtypes.html#dict" title="(in Python v2.7)"><em>dict</em></a>) &#8211; The dictionary to use</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.set_val">
<code class="descname">set_val</code><span class="sig-paren">(</span><em>key</em>, <em>val</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.set_val" title="Permalink to this definition"></a></dt>
<dd><p>Set a value in the dictionary. Will replace the first instance of the
key with the value. If multiple values of the keys are already in the
dictionary, the duplicates of the key will be removed and the first instance
of the key will be replaced with the value. If the dictionary is case
insensitive, it will maintain the original capitalization. This is the same
behavior as assigning a value via <code class="docutils literal"><span class="pre">d[key]</span> <span class="pre">=</span> <span class="pre">val</span></code>. If the key is not
present, it will be added to the end of the dict.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.RepeatableDict.sort">
<code class="descname">sort</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.RepeatableDict.sort" title="Permalink to this definition"></a></dt>
<dd><p>Sort the dictionary by the key. Requires that all keys can be compared
to each other</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pappyproxy.http.Request">
<em class="property">class </em><code class="descclassname">pappyproxy.http.</code><code class="descname">Request</code><span class="sig-paren">(</span><em>full_request=None</em>, <em>update_content_length=True</em>, <em>port=None</em>, <em>is_ssl=None</em>, <em>host=None</em>, <em>path_type=None</em>, <em>proxy_creds=None</em>, <em>explicit_port=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#pappyproxy.http.HTTPMessage" title="pappyproxy.http.HTTPMessage"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.http.HTTPMessage</span></code></a></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Variables:</th><td class="field-body"><ul class="first last simple">
<li><strong>time_end</strong> (<a class="reference external" href="https://docs.python.org/library/datetime.html#datetime.datetime" title="(in Python v2.7)"><em>datetime.datetime</em></a>) &#8211; The datetime that the request ended.</li>
<li><strong>time_start</strong> (<a class="reference external" href="https://docs.python.org/library/datetime.html#datetime.datetime" title="(in Python v2.7)"><em>datetime.datetime</em></a>) &#8211; The datetime that the request was made</li>
<li><strong>cookies</strong> (<a class="reference internal" href="#pappyproxy.http.RepeatableDict" title="pappyproxy.http.RepeatableDict"><em>RepeatableDict</em></a>) &#8211; Cookies sent with the request</li>
<li><strong>fragment</strong> (<em>String</em>) &#8211; The fragment part of the url (The part that comes after the #)</li>
<li><strong>url_params</strong> (<a class="reference internal" href="#pappyproxy.http.RepeatableDict" title="pappyproxy.http.RepeatableDict"><em>RepeatableDict</em></a>) &#8211; The url parameters of the request (aka the get parameters)</li>
<li><strong>path</strong> (<em>String</em>) &#8211; The path of the request</li>
<li><strong>port</strong> (<em>Integer</em>) &#8211; The port that the request was sent to (or will be sent to)</li>
<li><strong>post_params</strong> (<a class="reference internal" href="#pappyproxy.http.RepeatableDict" title="pappyproxy.http.RepeatableDict"><em>RepeatableDict</em></a>) &#8211; The post parameters of the request</li>
<li><strong>reqid</strong> (<em>String</em>) &#8211; The request id of the request</li>
<li><strong>response</strong> (<a class="reference internal" href="#pappyproxy.http.Response" title="pappyproxy.http.Response"><em>Response</em></a>) &#8211; The associated response of this request</li>
<li><strong>submitted</strong> (<em>Bool</em>) &#8211; Whether the request has been submitted</li>
<li><strong>unmangled</strong> (<a class="reference internal" href="#pappyproxy.http.Request" title="pappyproxy.http.Request"><em>Request</em></a>) &#8211; If the request was mangled, the version of the request
before it was mangled.</li>
<li><strong>verb</strong> (<em>String</em>) &#8211; The HTTP verb of the request (ie POST, GET)</li>
<li><strong>version</strong> (<em>String</em>) &#8211; The HTTP version of the request (ie HTTP/1.1)</li>
<li><strong>tags</strong> (<em>List of Strings</em>) &#8211; Tags associated with the request</li>
<li><strong>plugin_data</strong> (<em>Dict</em>) &#8211; Data about the request created by plugins. If you modify this, please add your own key to it for your plugin and store all your plugin&#8217;s data under that key (probably as another dict). For example if you have a plugin called <code class="docutils literal"><span class="pre">foo</span></code>, try and store all your data under <code class="docutils literal"><span class="pre">req.plugin_data['foo']</span></code>.</li>
<li><strong>path_type</strong> (<em>Enum</em>) &#8211; An enum which describes how the path portion of the request should be represented. <code class="docutils literal"><span class="pre">PATH_RELATIVE</span></code> -&gt; normal relative path, <code class="docutils literal"><span class="pre">PATH_ABSOLUTE</span></code> -&gt; The absolute path (including the protocol), <code class="docutils literal"><span class="pre">PATH_HOST</span></code> -&gt; Just the path and the port (Used for CONNECT requests when connecting to an upstream HTTP proxy).</li>
<li><strong>explicit_port</strong> &#8211; A flag to indicate that the port should always be included in the URL</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pappyproxy.http.Request.async_deep_save">
<code class="descname">async_deep_save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.async_deep_save" title="Permalink to this definition"></a></dt>
<dd><p>Saves self, unmangled, response, and unmangled response. Returns a deferred
which fires after everything has been saved.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">twisted.internet.defer.Deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Request.async_save">
<code class="descname">async_save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.async_save" title="Permalink to this definition"></a></dt>
<dd><p>Save/update the request in the data file. Returns a twisted deferred which
fires when the save is complete.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">twisted.internet.defer.Deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Request.async_submit">
<code class="descname">async_submit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.async_submit" title="Permalink to this definition"></a></dt>
<dd><p>Same as <a class="reference internal" href="#pappyproxy.http.Request.submit" title="pappyproxy.http.Request.submit"><code class="xref py py-func docutils literal"><span class="pre">submit()</span></code></a> but generates deferreds.
Submits the request using its host, port, etc. and updates its response value
to the resulting response.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mangle</strong> (<em>Bool</em>) &#8211; Whether to pass the request through active intercepting macros.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">Twisted deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.cache">
<code class="descname">cache</code><em class="property"> = &lt;pappyproxy.requestcache.RequestCache object&gt;</em><a class="headerlink" href="#pappyproxy.http.Request.cache" title="Permalink to this definition"></a></dt>
<dd><p>The request cache that stores requests in memory for performance</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.connect_request">
<code class="descname">connect_request</code><a class="headerlink" href="#pappyproxy.http.Request.connect_request" title="Permalink to this definition"></a></dt>
<dd><p>If the request uses SSL, this will be a request object that can be used
with an upstream HTTP server to connect to a server using SSL</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Request.deep_delete">
<code class="descname">deep_delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.deep_delete" title="Permalink to this definition"></a></dt>
<dd><p>Delete a request, its unmangled version, its response, and its response&#8217;s
unmangled version from history. Also removes the request from all contexts.
Returns a Twisted deferred.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.full_path">
<code class="descname">full_path</code><a class="headerlink" href="#pappyproxy.http.Request.full_path" title="Permalink to this definition"></a></dt>
<dd><p>The full path of the request including URL params and fragment.
ie <cite>/path/to/stuff?foo=bar&amp;baz=something#somewhere</cite></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the full path of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.full_request">
<code class="descname">full_request</code><a class="headerlink" href="#pappyproxy.http.Request.full_request" title="Permalink to this definition"></a></dt>
<dd><p>Alias for Request.full_message</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the full text of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Request.get_plugin_dict">
<code class="descname">get_plugin_dict</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.get_plugin_dict" title="Permalink to this definition"></a></dt>
<dd><p>Get the data dictionary for the given plugin name.</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.host">
<code class="descname">host</code><a class="headerlink" href="#pappyproxy.http.Request.host" title="Permalink to this definition"></a></dt>
<dd><p>The host of the request. ie <cite>www.google.com</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the host of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Changes the host of the request and updates the Host header</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.is_ssl">
<code class="descname">is_ssl</code><a class="headerlink" href="#pappyproxy.http.Request.is_ssl" title="Permalink to this definition"></a></dt>
<dd><p>Whether the request is sent over SSL</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns if the request is sent over SSL</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Sets if the request is sent over SSL</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">Bool</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="staticmethod">
<dt id="pappyproxy.http.Request.load_request">
<em class="property">static </em><code class="descname">load_request</code><span class="sig-paren">(</span><em>to_load</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.load_request" title="Permalink to this definition"></a></dt>
<dd><p>Load a request with the given request id and return it.
Returns a deferred which calls back with the request when complete.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>allow_special</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v2.7)"><em>bool</em></a>) &#8211; Whether to allow special IDs such as <code class="docutils literal"><span class="pre">u##</span></code> or <code class="docutils literal"><span class="pre">s##</span></code></li>
<li><strong>use_cache</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v2.7)"><em>bool</em></a>) &#8211; Whether to use the cache. If set to false, it will always query the data file to get the request</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">twisted.internet.defer.Deferred</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="staticmethod">
<dt id="pappyproxy.http.Request.load_requests_by_tag">
<em class="property">static </em><code class="descname">load_requests_by_tag</code><span class="sig-paren">(</span><em>tag</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.load_requests_by_tag" title="Permalink to this definition"></a></dt>
<dd><p>Load all the requests in the data file with a given tag and return them in a list.
Returns a deferred which calls back with the list of requests when complete.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">twisted.internet.defer.Deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="staticmethod">
<dt id="pappyproxy.http.Request.load_requests_by_time">
<em class="property">static </em><code class="descname">load_requests_by_time</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.load_requests_by_time" title="Permalink to this definition"></a></dt>
<dd><p>Load all the requests in the data file and return them in a list.
Returns a deferred which calls back with the list of requests when complete.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">twisted.internet.defer.Deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.path_tuple">
<code class="descname">path_tuple</code><a class="headerlink" href="#pappyproxy.http.Request.path_tuple" title="Permalink to this definition"></a></dt>
<dd><p>The path in tuple form starting with the host. For example, path_parts for
a request to <a class="reference external" href="http://www.example.com/foo/bar.php">http://www.example.com/foo/bar.php</a> would be:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="p">(</span><span class="s1">&#39;www.example.com&#39;</span><span class="p">,</span> <span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="s1">&#39;bar.php&#39;</span><span class="p">)</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the path in tuple form</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">Tuple</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.proxy_creds">
<code class="descname">proxy_creds</code><a class="headerlink" href="#pappyproxy.http.Request.proxy_creds" title="Permalink to this definition"></a></dt>
<dd><p>A username/password tuple representing the username/password to
authenticate to a proxy server. Sets the <code class="docutils literal"><span class="pre">Proxy-Authorization</span></code>
header. Getter will return (None, None) if no creds exist</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the username/password tuple used for proxy authorization</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Sets the username/password tuple used for proxy authorization</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">Tuple of two strings: (username, password)</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.raw_data">
<code class="descname">raw_data</code><a class="headerlink" href="#pappyproxy.http.Request.raw_data" title="Permalink to this definition"></a></dt>
<dd><p>Alias for Request.body</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the data portion of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Set the data of the request and update metadata</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.raw_headers">
<code class="descname">raw_headers</code><a class="headerlink" href="#pappyproxy.http.Request.raw_headers" title="Permalink to this definition"></a></dt>
<dd><p>Alias for Request.headers_section</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the raw text of the headers including the extra newline at the end.</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.rsptime">
<code class="descname">rsptime</code><a class="headerlink" href="#pappyproxy.http.Request.rsptime" title="Permalink to this definition"></a></dt>
<dd><p>The response time of the request</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the response time of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">datetime.timedelta</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Request.save">
<code class="descname">save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.save" title="Permalink to this definition"></a></dt>
<dd><p>Save/update the request in the data file.
Saves the request, its unmangled version, the response, and the unmanbled response.
Cannot be called from inside an async function.</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.saved">
<code class="descname">saved</code><a class="headerlink" href="#pappyproxy.http.Request.saved" title="Permalink to this definition"></a></dt>
<dd><p>If the request is saved in the data file</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns True if the request is saved in the data file</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">Bool</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.sort_time">
<code class="descname">sort_time</code><a class="headerlink" href="#pappyproxy.http.Request.sort_time" title="Permalink to this definition"></a></dt>
<dd><p>If the request has a submit time, returns the submit time&#8217;s unix timestamp.
Returns 0 otherwise</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.start_line">
<code class="descname">start_line</code><a class="headerlink" href="#pappyproxy.http.Request.start_line" title="Permalink to this definition"></a></dt>
<dd><p>The status line of the request. ie <cite>GET / HTTP/1.1</cite></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the status line of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Sets the status line of the request</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.status_line">
<code class="descname">status_line</code><a class="headerlink" href="#pappyproxy.http.Request.status_line" title="Permalink to this definition"></a></dt>
<dd><p>Alias for <cite>pappyproxy.http.Request.start_line</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the status line of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Sets the status line of the request</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Request.submit">
<code class="descname">submit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.submit" title="Permalink to this definition"></a></dt>
<dd><p>Submits the request using its host, port, etc. and updates its response value
to the resulting response.
Cannot be called in async functions.
This is what you should use to submit your requests in macros.</p>
</dd></dl>
<dl class="staticmethod">
<dt id="pappyproxy.http.Request.submit_request">
<em class="property">static </em><code class="descname">submit_request</code><span class="sig-paren">(</span><em>request</em>, <em>save_request=False</em>, <em>intercepting_macros={}</em>, <em>stream_transport=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Request.submit_request" title="Permalink to this definition"></a></dt>
<dd><p>Submits the request then sets <code class="docutils literal"><span class="pre">request.response</span></code>. Returns a deferred that
is called with the request that was submitted.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> &#8211; The request to submit</li>
<li><strong>save_request</strong> (<em>Bool</em>) &#8211; Whether to save the request to history</li>
<li><strong>intercepting_macros</strong> (<em>Dict or collections.OrderedDict</em>) &#8211; Dictionary of intercepting macros to be applied to the request</li>
<li><strong>stream_transport</strong> (<em>twisted.internet.interfaces.ITransport</em>) &#8211; Return transport to stream to. Set to None to not stream the response.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.url">
<code class="descname">url</code><a class="headerlink" href="#pappyproxy.http.Request.url" title="Permalink to this definition"></a></dt>
<dd><p>The full url of the request including url params, protocol, etc.
ie <cite>https://www.google.com</cite>, <cite>http://foo.fakewebsite.com:1234/path?a=b</cite>.
When setting the URL, the port, is_ssl, path, url params, host, etc are all
automatically updated.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the url of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Sets the url of the request and updates metadata</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Request.url_color">
<code class="descname">url_color</code><a class="headerlink" href="#pappyproxy.http.Request.url_color" title="Permalink to this definition"></a></dt>
<dd><p>same as .url, except colored. Used for printing URLs to the terminal.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the url of the request</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pappyproxy.http.Response">
<em class="property">class </em><code class="descclassname">pappyproxy.http.</code><code class="descname">Response</code><span class="sig-paren">(</span><em>full_response=None</em>, <em>update_content_length=True</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Response" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#pappyproxy.http.HTTPMessage" title="pappyproxy.http.HTTPMessage"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.http.HTTPMessage</span></code></a></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Variables:</th><td class="field-body"><ul class="first last simple">
<li><strong>cookies</strong> (<em>RepeatableDict of ResponseCookie objects</em>) &#8211; Cookies set by the response</li>
<li><strong>response_code</strong> (<em>Integer</em>) &#8211; The response code of the response</li>
<li><strong>response_text</strong> (<em>String</em>) &#8211; The text associated with the response code (ie OK, NOT FOUND, etc)</li>
<li><strong>rspid</strong> (<em>String</em>) &#8211; If the response is saved in the data file, the id of the response</li>
<li><strong>unmangled</strong> (<a class="reference internal" href="#pappyproxy.http.Response" title="pappyproxy.http.Response"><em>Response</em></a>) &#8211; If the response was mangled, the unmangled version of the response</li>
<li><strong>version</strong> (<em>String</em>) &#8211; The version part of the status line (ie HTTP/1.1)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pappyproxy.http.Response.add_cookie">
<code class="descname">add_cookie</code><span class="sig-paren">(</span><em>cookie</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Response.add_cookie" title="Permalink to this definition"></a></dt>
<dd><p>Add a <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.http.ResponseCookie</span></code></a> to the response.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This will add duplicate cookies. If you want to add a cookie you&#8217;re not sure exists,
use <a class="reference internal" href="#pappyproxy.http.Response.set_cookie" title="pappyproxy.http.Response.set_cookie"><code class="xref py py-func docutils literal"><span class="pre">set_cookie()</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Response.async_save">
<code class="descname">async_save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Response.async_save" title="Permalink to this definition"></a></dt>
<dd><p>Save/update the just request in the data file. Returns a twisted deferred which
fires when the save is complete. It is suggested that you use
:func: <cite>~pappyproxy.http.Request.async_deep_save</cite> instead to save responses.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">twisted.internet.defer.Deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Response.delete_cookie">
<code class="descname">delete_cookie</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Response.delete_cookie" title="Permalink to this definition"></a></dt>
<dd><p>Delete a cookie from the response by its key</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Response.full_response">
<code class="descname">full_response</code><a class="headerlink" href="#pappyproxy.http.Response.full_response" title="Permalink to this definition"></a></dt>
<dd><p>The full text of the response including the headers and data.
Alias for Response.full_message</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the full text of the response</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="staticmethod">
<dt id="pappyproxy.http.Response.load_response">
<em class="property">static </em><code class="descname">load_response</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Response.load_response" title="Permalink to this definition"></a></dt>
<dd><p>Load a response from its response id. Returns a deferred. I don&#8217;t suggest you use this.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">twisted.internet.defer.Deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Response.raw_data">
<code class="descname">raw_data</code><a class="headerlink" href="#pappyproxy.http.Response.raw_data" title="Permalink to this definition"></a></dt>
<dd><p>Alias for Response.body</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the data portion of the response</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Set the data of the response and update metadata</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Response.raw_headers">
<code class="descname">raw_headers</code><a class="headerlink" href="#pappyproxy.http.Response.raw_headers" title="Permalink to this definition"></a></dt>
<dd><p>Alias for Response.headers_section</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the raw text of the headers including the extra newline at the end.</td>
</tr>
<tr class="field-even field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Response.set_cookie">
<code class="descname">set_cookie</code><span class="sig-paren">(</span><em>cookie</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Response.set_cookie" title="Permalink to this definition"></a></dt>
<dd><p>Set a cookie in the response. <code class="docutils literal"><span class="pre">cookie</span></code> must be a <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.http.ResponseCookie</span></code></a></p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.http.Response.set_cookie_kv">
<code class="descname">set_cookie_kv</code><span class="sig-paren">(</span><em>key</em>, <em>val</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.Response.set_cookie_kv" title="Permalink to this definition"></a></dt>
<dd><p>Set a cookie by key and value. Will not have path, secure, etc set at all.</p>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Response.soup">
<code class="descname">soup</code><a class="headerlink" href="#pappyproxy.http.Response.soup" title="Permalink to this definition"></a></dt>
<dd><p>Returns a beautifulsoup4 object for parsing the html of the response</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns a BeautifulSoup object representing the html of the response</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="pappyproxy.http.Response.start_line">
<code class="descname">start_line</code><a class="headerlink" href="#pappyproxy.http.Response.start_line" title="Permalink to this definition"></a></dt>
<dd><p>The status line of the response. ie <cite>HTTP/1.1 200 OK</cite></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the status line of the response</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Sets the status line of the response</td>
</tr>
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">string</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pappyproxy.http.ResponseCookie">
<em class="property">class </em><code class="descclassname">pappyproxy.http.</code><code class="descname">ResponseCookie</code><span class="sig-paren">(</span><em>set_cookie_string=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.ResponseCookie" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>A cookie representing a cookie set by a response</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Variables:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> &#8211; The key of the cookie</li>
<li><strong>val</strong> &#8211; The value of the cookie</li>
<li><strong>expires</strong> &#8211; The value of the &#8220;expires&#8221; attribute</li>
<li><strong>max_age</strong> &#8211; The max age of the cookie</li>
<li><strong>domain</strong> &#8211; The domain of the cookie</li>
<li><strong>path</strong> &#8211; The path of the cookie</li>
<li><strong>secure</strong> &#8211; The secure flag of the cookie</li>
<li><strong>http_only</strong> &#8211; The httponly flag of the cookie</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="pappyproxy.http.ResponseCookie.cookie_str">
<code class="descname">cookie_str</code><a class="headerlink" href="#pappyproxy.http.ResponseCookie.cookie_str" title="Permalink to this definition"></a></dt>
<dd><p>Returns the full string of the cookie. ie <code class="docutils literal"><span class="pre">foo=bar;</span> <span class="pre">secure;</span> <span class="pre">path=/</span></code></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Getter:</th><td class="field-body">Returns the full string of the cookie.</td>
</tr>
<tr class="field-even field"><th class="field-name">Setter:</th><td class="field-body">Set the metadata from a cookie string. ie from a <code class="docutils literal"><span class="pre">Set-Cookie</span></code> header</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.http.async_submit_requests">
<code class="descclassname">pappyproxy.http.</code><code class="descname">async_submit_requests</code><span class="sig-paren">(</span><em>reqs</em>, <em>mangle=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.async_submit_requests" title="Permalink to this definition"></a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mangle</strong> (<em>Bool</em>) &#8211; Whether to pass the requests through intercepting macros</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">DeferredList</td>
</tr>
</tbody>
</table>
<p>Submits a list of requests at the same time asynchronously.
Responses/unmangled versions will be attached to the request objects in the list.
Prints progress to stdout.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.http.get_request">
<code class="descclassname">pappyproxy.http.</code><code class="descname">get_request</code><span class="sig-paren">(</span><em>url=''</em>, <em>url_params={}</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.get_request" title="Permalink to this definition"></a></dt>
<dd><p>Create a request object that makes a GET request to the given url with the
given url params.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.http.init">
<code class="descclassname">pappyproxy.http.</code><code class="descname">init</code><span class="sig-paren">(</span><em>pool</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.init" title="Permalink to this definition"></a></dt>
<dd><p>Initialize the http module.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>pool</strong> (<em>SQLite ConnectionPool</em>) &#8211; The ConnectionPool to use to store the request/response objects</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.http.post_request">
<code class="descclassname">pappyproxy.http.</code><code class="descname">post_request</code><span class="sig-paren">(</span><em>url</em>, <em>post_params={}</em>, <em>url_params={}</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.http.post_request" title="Permalink to this definition"></a></dt>
<dd><p>Create a request object that makes a POST request to the given url with the
given post and url params.</p>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.iter">
<span id="pappyproxy-iter-module"></span><h2>pappyproxy.iter module<a class="headerlink" href="#module-pappyproxy.iter" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="pappyproxy.iter.common_passwords">
<code class="descclassname">pappyproxy.iter.</code><code class="descname">common_passwords</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.iter.common_passwords" title="Permalink to this definition"></a></dt>
<dd><p>List common passwords</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.iter.common_usernames">
<code class="descclassname">pappyproxy.iter.</code><code class="descname">common_usernames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.iter.common_usernames" title="Permalink to this definition"></a></dt>
<dd><p>List common usernames</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.iter.fuzz_path_trav">
<code class="descclassname">pappyproxy.iter.</code><code class="descname">fuzz_path_trav</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.iter.fuzz_path_trav" title="Permalink to this definition"></a></dt>
<dd><p>Fuzz common values for path traversal.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.iter.fuzz_sqli">
<code class="descclassname">pappyproxy.iter.</code><code class="descname">fuzz_sqli</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.iter.fuzz_sqli" title="Permalink to this definition"></a></dt>
<dd><p>Fuzz common values that could cause sql errors</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.iter.fuzz_xss">
<code class="descclassname">pappyproxy.iter.</code><code class="descname">fuzz_xss</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.iter.fuzz_xss" title="Permalink to this definition"></a></dt>
<dd><p>Fuzz values for finding XSS</p>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.macros">
<span id="pappyproxy-macros-module"></span><h2>pappyproxy.macros module<a class="headerlink" href="#module-pappyproxy.macros" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="pappyproxy.macros.FileInterceptMacro">
<em class="property">class </em><code class="descclassname">pappyproxy.macros.</code><code class="descname">FileInterceptMacro</code><span class="sig-paren">(</span><em>filename=''</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.macros.FileInterceptMacro" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#pappyproxy.macros.InterceptMacro" title="pappyproxy.macros.InterceptMacro"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.macros.InterceptMacro</span></code></a></p>
<p>An intercepting macro that loads a macro from a file.</p>
</dd></dl>
<dl class="class">
<dt id="pappyproxy.macros.InterceptMacro">
<em class="property">class </em><code class="descclassname">pappyproxy.macros.</code><code class="descname">InterceptMacro</code><a class="headerlink" href="#pappyproxy.macros.InterceptMacro" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>A class representing a macro that modifies requests as they pass through the
proxy</p>
</dd></dl>
<dl class="class">
<dt id="pappyproxy.macros.Macro">
<em class="property">class </em><code class="descclassname">pappyproxy.macros.</code><code class="descname">Macro</code><span class="sig-paren">(</span><em>filename=''</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.macros.Macro" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>A class representing a macro that can perform a series of requests and add
data to storage.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.macros.load_macros">
<code class="descclassname">pappyproxy.macros.</code><code class="descname">load_macros</code><span class="sig-paren">(</span><em>loc</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.macros.load_macros" title="Permalink to this definition"></a></dt>
<dd><p>Loads the macros stored in the location and returns a list of Macro objects</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.macros.mangle_request">
<code class="descclassname">pappyproxy.macros.</code><code class="descname">mangle_request</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.macros.mangle_request" title="Permalink to this definition"></a></dt>
<dd><p>Mangle a request with a list of intercepting macros.
Returns a tuple that contains the resulting request (with its unmangled
value set if needed) and a bool that states whether the request was modified
Returns (None, True) if the request was dropped.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">(Request, Bool)</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.macros.mangle_response">
<code class="descclassname">pappyproxy.macros.</code><code class="descname">mangle_response</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.macros.mangle_response" title="Permalink to this definition"></a></dt>
<dd><p>Mangle a request&#8217;s response with a list of intercepting macros.
Returns a bool stating whether the request&#8217;s response was modified.
Unmangled values will be updated as needed.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Bool</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.pappy">
<span id="pappyproxy-pappy-module"></span><h2>pappyproxy.pappy module<a class="headerlink" href="#module-pappyproxy.pappy" title="Permalink to this headline"></a></h2>
<p>Handles the main Pappy session.</p>
<dl class="data">
<dt id="pappyproxy.pappy.session">
<code class="descclassname">pappyproxy.pappy.</code><code class="descname">session</code><a class="headerlink" href="#pappyproxy.pappy.session" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>The <a class="reference internal" href="#pappyproxy.pappy.PappySession" title="pappyproxy.pappy.PappySession"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.pappy.PappySession</span></code></a> object for the current session. Mainly
used for accessing the session&#8217;s config information.</p>
<dl class="class">
<dt id="pappyproxy.pappy.PappySession">
<em class="property">class </em><code class="descclassname">pappyproxy.pappy.</code><code class="descname">PappySession</code><span class="sig-paren">(</span><em>sessconfig</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.pappy.PappySession" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>An object representing a pappy session. Mainly you&#8217;ll only use this to get to
the session config.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Variables:</th><td class="field-body"><a class="reference internal" href="#module-pappyproxy.config" title="pappyproxy.config"><strong>config</strong></a> (<a class="reference internal" href="#pappyproxy.config.PappyConfig" title="pappyproxy.config.PappyConfig"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.config.PappyConfig</span></code></a>) &#8211; The configuration settings for the session</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.plugin">
<span id="pappyproxy-plugin-module"></span><h2>pappyproxy.plugin module<a class="headerlink" href="#module-pappyproxy.plugin" title="Permalink to this headline"></a></h2>
<p>This module contains all the api calls written for use in plugins. If you want
to do anything that is&#8217;t allowed through these function calls or through the
functions provided for macros, contact me and I&#8217;ll see what I can do to add some
more functionality into the next version.</p>
<dl class="function">
<dt id="pappyproxy.plugin.active_intercepting_macros">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">active_intercepting_macros</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.active_intercepting_macros" title="Permalink to this definition"></a></dt>
<dd><p>Returns a dict of the active intercepting macro objects. Modifying
this list will not affect which macros are active.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.add_intercepting_macro">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">add_intercepting_macro</code><span class="sig-paren">(</span><em>name</em>, <em>macro</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.add_intercepting_macro" title="Permalink to this definition"></a></dt>
<dd><p>Adds an intercepting macro to the proxy. You can either use a
<a class="reference internal" href="#pappyproxy.macros.FileInterceptMacro" title="pappyproxy.macros.FileInterceptMacro"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.macros.FileInterceptMacro</span></code></a> to load an
intercepting macro from the disk, or you can create your own using
an <a class="reference internal" href="#pappyproxy.macros.InterceptMacro" title="pappyproxy.macros.InterceptMacro"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.macros.InterceptMacro</span></code></a> for a base class. You
must give a unique name that will be used in
<a class="reference internal" href="#pappyproxy.plugin.remove_intercepting_macro" title="pappyproxy.plugin.remove_intercepting_macro"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.plugin.remove_intercepting_macro()</span></code></a> to deactivate
it. Remember that activating an intercepting macro will disable
request streaming and will affect performance. So please try and
only use this if you may need to modify messages before they are
passed along.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.add_to_history">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">add_to_history</code><span class="sig-paren">(</span><em>req</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.add_to_history" title="Permalink to this definition"></a></dt>
<dd><p>Save a request to history without saving it to the data file. The request
will only be saved in memory, so when the program is exited or <cite>clrmem</cite>
is run, the request will be deleted.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>req</strong> (<a class="reference internal" href="#pappyproxy.http.Request" title="pappyproxy.http.Request"><code class="xref py py-class docutils literal"><span class="pre">pappyproxy.http.Request</span></code></a>) &#8211; The request to add to history</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.async_main_context_ids">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">async_main_context_ids</code><span class="sig-paren">(</span><em>n=-1</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.async_main_context_ids" title="Permalink to this definition"></a></dt>
<dd><p>Returns a deferred that resolves into a list of up to <code class="docutils literal"><span class="pre">n</span></code> of the
most recent requests in the main context. You can then use
<a class="reference internal" href="#pappyproxy.http.Request.load_request" title="pappyproxy.http.Request.load_request"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.http.Request.load_request()</span></code></a> to load the requests
in the current context. If no value is passed for <code class="docutils literal"><span class="pre">n</span></code>, this will
return all of the IDs in the context.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.in_memory_reqs">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">in_memory_reqs</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.in_memory_reqs" title="Permalink to this definition"></a></dt>
<dd><p>Returns a list containing the ids of the requests which exist in
memory only (requests with an m## style id). You can call either
<a class="reference internal" href="#pappyproxy.http.Request.save" title="pappyproxy.http.Request.save"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.http.Request.save()</span></code></a> or
<a class="reference internal" href="#pappyproxy.http.Request.async_deep_save" title="pappyproxy.http.Request.async_deep_save"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.http.Request.async_deep_save()</span></code></a> to save the
request to the data file.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.main_context_ids">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">main_context_ids</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.main_context_ids" title="Permalink to this definition"></a></dt>
<dd><p>Same as <a class="reference internal" href="#pappyproxy.plugin.async_main_context_ids" title="pappyproxy.plugin.async_main_context_ids"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.plugin.async_main_context_ids()</span></code></a> but can be called
from macros and other non-async only functions. Cannot be called in async
functions.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.plugin_by_name">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">plugin_by_name</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.plugin_by_name" title="Permalink to this definition"></a></dt>
<dd><p>Returns an interface to access the methods of a plugin from its
name. For example, to call the <code class="docutils literal"><span class="pre">foo</span></code> function from the <code class="docutils literal"><span class="pre">bar</span></code>
plugin you would call <code class="docutils literal"><span class="pre">plugin_by_name('bar').foo()</span></code>.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.remove_intercepting_macro">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">remove_intercepting_macro</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.remove_intercepting_macro" title="Permalink to this definition"></a></dt>
<dd><p>Stops an active intercepting macro. You must pass in the name that
you used when calling
<a class="reference internal" href="#pappyproxy.plugin.add_intercepting_macro" title="pappyproxy.plugin.add_intercepting_macro"><code class="xref py py-func docutils literal"><span class="pre">pappyproxy.plugin.add_intercepting_macro()</span></code></a> to identify which
macro you would like to stop.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.req_history">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">req_history</code><span class="sig-paren">(</span><em>num=-1</em>, <em>ids=None</em>, <em>include_unmangled=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.req_history" title="Permalink to this definition"></a></dt>
<dd><p>Returns an a generator that generates deferreds which resolve to
requests in history, ignoring the current context. If <code class="docutils literal"><span class="pre">n</span></code> is
given, it will stop after <code class="docutils literal"><span class="pre">n</span></code> requests have been generated. If
<code class="docutils literal"><span class="pre">ids</span></code> is given, it will only include those IDs. If
<code class="docutils literal"><span class="pre">include_unmangled</span></code> is True, then the iterator will include
requests which are the unmangled version of other requests.</p>
<p>An example of using the iterator to print the 10 most recent requests:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="nd">@defer.inlineCallbacks</span>
<span class="k">def</span> <span class="nf">find_food</span><span class="p">():</span>
<span class="k">for</span> <span class="n">req_d</span> <span class="ow">in</span> <span class="n">req_history</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span>
<span class="n">req</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">req_d</span>
<span class="k">print</span> <span class="s1">&#39;-&#39;</span><span class="o">*</span><span class="mi">10</span>
<span class="k">print</span> <span class="n">req</span><span class="o">.</span><span class="n">full_message_pretty</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.require_modules">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">require_modules</code><span class="sig-paren">(</span><em>*largs</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.require_modules" title="Permalink to this definition"></a></dt>
<dd><p>A wrapper to make sure that plugin dependencies are installed. For example,
if a command requires the <code class="docutils literal"><span class="pre">psutil</span></code> and <code class="docutils literal"><span class="pre">objgraph</span></code> package, you should
format your command like:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="nd">@require_modules</span><span class="p">(</span><span class="s1">&#39;psutil&#39;</span><span class="p">,</span> <span class="s1">&#39;objgraph&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">my_command</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
<span class="kn">import</span> <span class="nn">objgraph</span>
<span class="kn">import</span> <span class="nn">psutil</span>
<span class="c1"># ... rest of command ...</span>
</pre></div>
</div>
<p>If you try to run the command without being able to import all of the required
modules, the command will print an error and not run the command.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.plugin.run_cmd">
<code class="descclassname">pappyproxy.plugin.</code><code class="descname">run_cmd</code><span class="sig-paren">(</span><em>cmd</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.plugin.run_cmd" title="Permalink to this definition"></a></dt>
<dd><p>Run a command as if you typed it into the console. Try and use
existing APIs to do what you want before using this.</p>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.proxy">
<span id="pappyproxy-proxy-module"></span><h2>pappyproxy.proxy module<a class="headerlink" href="#module-pappyproxy.proxy" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-pappyproxy.repeater">
<span id="pappyproxy-repeater-module"></span><h2>pappyproxy.repeater module<a class="headerlink" href="#module-pappyproxy.repeater" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-pappyproxy.session">
<span id="pappyproxy-session-module"></span><h2>pappyproxy.session module<a class="headerlink" href="#module-pappyproxy.session" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="pappyproxy.session.Session">
<em class="property">class </em><code class="descclassname">pappyproxy.session.</code><code class="descname">Session</code><span class="sig-paren">(</span><em>cookie_names=None</em>, <em>header_names=None</em>, <em>cookie_vals=None</em>, <em>header_vals=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/functions.html#object" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">object</span></code></a></p>
<p>A class used to maintain a session over multiple requests. Can remember cookies
and apply a specific header to requests. It is also possible to give the session
a list of cookie names and it will only save those cookies.</p>
<dl class="method">
<dt id="pappyproxy.session.Session.apply_req">
<code class="descname">apply_req</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session.apply_req" title="Permalink to this definition"></a></dt>
<dd><p>Apply saved headers and cookies to the request</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.session.Session.apply_rsp">
<code class="descname">apply_rsp</code><span class="sig-paren">(</span><em>response</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session.apply_rsp" title="Permalink to this definition"></a></dt>
<dd><p>Will add a Set-Cookie header for each saved cookie. Will not
apply any saved headers. If the cookie was added from a call to
<a class="reference internal" href="#pappyproxy.session.Session.save_rsp" title="pappyproxy.session.Session.save_rsp"><code class="xref py py-func docutils literal"><span class="pre">save_rsp()</span></code></a>, the Set-Cookie flags
will be the same as the original response.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.session.Session.get_cookie">
<code class="descname">get_cookie</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session.get_cookie" title="Permalink to this definition"></a></dt>
<dd><p>Returns a string with the value of the cookie with the given string, even if the value is a <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">ResponseCookie</span></code></a>.
If you want to get a <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">ResponseCookie</span></code></a>, use <a class="reference internal" href="#pappyproxy.session.Session.get_rsp_cookie" title="pappyproxy.session.Session.get_rsp_cookie"><code class="xref py py-func docutils literal"><span class="pre">get_rsp_cookie()</span></code></a>.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.session.Session.get_rsp_cookie">
<code class="descname">get_rsp_cookie</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session.get_rsp_cookie" title="Permalink to this definition"></a></dt>
<dd><p>Returns the <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">ResponseCookie</span></code></a> associated with the key
regardless of if the value is stored as a string or a <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">ResponseCookie</span></code></a>.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.session.Session.save_req">
<code class="descname">save_req</code><span class="sig-paren">(</span><em>req</em>, <em>cookies=None</em>, <em>headers=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session.save_req" title="Permalink to this definition"></a></dt>
<dd><p>Updates the state of the session from the given request.
Cookie and headers can be added to their whitelists by passing in a list
for either <code class="docutils literal"><span class="pre">cookies</span></code> or <code class="docutils literal"><span class="pre">headers</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.session.Session.save_rsp">
<code class="descname">save_rsp</code><span class="sig-paren">(</span><em>rsp</em>, <em>cookies=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session.save_rsp" title="Permalink to this definition"></a></dt>
<dd><p>Update the state of the session from the response. Only cookies can be
updated from a response. Additional values can be added to the whitelist
by passing in a list of values for the <code class="docutils literal"><span class="pre">cookies</span></code> parameter. If save_all
is given, all set cookies will be added to the session.</p>
</dd></dl>
<dl class="method">
<dt id="pappyproxy.session.Session.set_cookie">
<code class="descname">set_cookie</code><span class="sig-paren">(</span><em>key</em>, <em>val</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.session.Session.set_cookie" title="Permalink to this definition"></a></dt>
<dd><p>Set a cookie in the session. <code class="docutils literal"><span class="pre">val</span></code> can be either a string or a <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">ResponseCookie</span></code></a>.
If a <a class="reference internal" href="#pappyproxy.http.ResponseCookie" title="pappyproxy.http.ResponseCookie"><code class="xref py py-class docutils literal"><span class="pre">ResponseCookie</span></code></a> is used, make sure its <code class="docutils literal"><span class="pre">key</span></code> value is the same as
the key passed in to the function.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy.util">
<span id="pappyproxy-util-module"></span><h2>pappyproxy.util module<a class="headerlink" href="#module-pappyproxy.util" title="Permalink to this headline"></a></h2>
<dl class="exception">
<dt id="pappyproxy.util.PappyException">
<em class="property">exception </em><code class="descclassname">pappyproxy.util.</code><code class="descname">PappyException</code><a class="headerlink" href="#pappyproxy.util.PappyException" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/library/exceptions.html#exceptions.Exception" title="(in Python v2.7)"><code class="xref py py-class docutils literal"><span class="pre">exceptions.Exception</span></code></a></p>
<p>The exception class for Pappy. If a plugin command raises one of these, the
message will be printed to the console rather than displaying a traceback.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.util.confirm">
<code class="descclassname">pappyproxy.util.</code><code class="descname">confirm</code><span class="sig-paren">(</span><em>message</em>, <em>default='n'</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.util.confirm" title="Permalink to this definition"></a></dt>
<dd><p>A helper function to get confirmation from the user. It prints <code class="docutils literal"><span class="pre">message</span></code>
then asks the user to answer yes or no. Returns True if the user answers
yes, otherwise returns False.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.util.get_req_data_row">
<code class="descclassname">pappyproxy.util.</code><code class="descname">get_req_data_row</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.util.get_req_data_row" title="Permalink to this definition"></a></dt>
<dd><p>Get the row data for a request to be printed.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.util.load_reqlist">
<code class="descclassname">pappyproxy.util.</code><code class="descname">load_reqlist</code><span class="sig-paren">(</span><em>line</em>, <em>allow_special=True</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.util.load_reqlist" title="Permalink to this definition"></a></dt>
<dd><p>A helper function for parsing a list of requests that are passed as an
argument. If <code class="docutils literal"><span class="pre">allow_special</span></code> is True, then it will parse IDs such as
<code class="docutils literal"><span class="pre">u123</span></code> or <code class="docutils literal"><span class="pre">s123</span></code>. Even if allow_special is false, it will still parse
<code class="docutils literal"><span class="pre">m##</span></code> IDs. Will print any errors with loading any of the requests and
will return a list of all the requests which were successfully loaded.
Returns a deferred.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Twisted deferred</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.util.print_request_rows">
<code class="descclassname">pappyproxy.util.</code><code class="descname">print_request_rows</code><span class="sig-paren">(</span><em>request_rows</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.util.print_request_rows" title="Permalink to this definition"></a></dt>
<dd><p>Takes in a list of request rows generated from <code class="xref py py-func docutils literal"><span class="pre">pappyproxy.console.get_req_data_row()</span></code>
and prints a table with data on each of the
requests. Used instead of <code class="xref py py-func docutils literal"><span class="pre">pappyproxy.console.print_requests()</span></code> if you
can&#8217;t count on storing all the requests in memory at once.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.util.print_requests">
<code class="descclassname">pappyproxy.util.</code><code class="descname">print_requests</code><span class="sig-paren">(</span><em>requests</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.util.print_requests" title="Permalink to this definition"></a></dt>
<dd><p>Takes in a list of requests and prints a table with data on each of the
requests. It&#8217;s the same table that&#8217;s used by <code class="docutils literal"><span class="pre">ls</span></code>.</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.util.print_table">
<code class="descclassname">pappyproxy.util.</code><code class="descname">print_table</code><span class="sig-paren">(</span><em>coldata</em>, <em>rows</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.util.print_table" title="Permalink to this definition"></a></dt>
<dd><p>Print a table.
Coldata: List of dicts with info on how to print the columns.
<code class="docutils literal"><span class="pre">name</span></code> is the heading to give column,
<code class="docutils literal"><span class="pre">width</span> <span class="pre">(optional)</span></code> maximum width before truncating. 0 for unlimited.</p>
<p>Rows: List of tuples with the data to print</p>
</dd></dl>
<dl class="function">
<dt id="pappyproxy.util.printable_data">
<code class="descclassname">pappyproxy.util.</code><code class="descname">printable_data</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#pappyproxy.util.printable_data" title="Permalink to this definition"></a></dt>
<dd><p>Return <code class="docutils literal"><span class="pre">data</span></code>, but replaces unprintable characters with periods.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>String</em>) &#8211; The data to make printable</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">String</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-pappyproxy">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-pappyproxy" title="Permalink to this headline"></a></h2>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">pappyproxy package</a><ul>
<li><a class="reference internal" href="#subpackages">Subpackages</a></li>
<li><a class="reference internal" href="#submodules">Submodules</a></li>
<li><a class="reference internal" href="#module-pappyproxy.comm">pappyproxy.comm module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.config">pappyproxy.config module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.console">pappyproxy.console module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.context">pappyproxy.context module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.http">pappyproxy.http module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.iter">pappyproxy.iter module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.macros">pappyproxy.macros module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.pappy">pappyproxy.pappy module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.plugin">pappyproxy.plugin module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.proxy">pappyproxy.proxy module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.repeater">pappyproxy.repeater module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.session">pappyproxy.session module</a></li>
<li><a class="reference internal" href="#module-pappyproxy.util">pappyproxy.util module</a></li>
<li><a class="reference internal" href="#module-pappyproxy">Module contents</a></li>
</ul>
</li>
</ul>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/pappyproxy.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Pappy Proxy 0.2.11 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&copy; Copyright 2015, Rob Glew.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.6.
</div>
</body>
</html>