From f0122f1403bc92eac790ca2b4e1d06bcf45bf745 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 6 Aug 2011 13:19:46 +1200 Subject: API docs. --- doc-src/scripts.html | 64 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 7 deletions(-) (limited to 'doc-src/scripts.html') diff --git a/doc-src/scripts.html b/doc-src/scripts.html index af140901..f3df489d 100644 --- a/doc-src/scripts.html +++ b/doc-src/scripts.html @@ -57,15 +57,65 @@ Called when a client disconnects from the proxy. Called once on script shutdown, after any other events. -## Scripts on saved flows - -There are a few circumstances in which a script may run on Flows that are -already complete. For example, you could start a script, and then load a saved -set of flows from a file (see the scripted data transformation example on the -[mitmdump](@!urlTo("mitmdump.html")!@) page). This also happens when you run a +## API + +The main classes you will deal with in writing mitmproxy scripts are: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
libmproxy.flow.ScriptContextA handle for interacting with mitmproxy's global state.
libmproxy.flow.FlowA collection of objects representing a single HTTP transaction.
libmproxy.flow.RequestAn HTTP request.
libmproxy.flow.ResponseAn HTTP response.
libmproxy.flow.ErrorA communications error.
libmproxy.flow.ClientConnectionDescribes a client connection.
libmproxy.flow.ClientDisconnectionDescribes a client disconnection.
libmproxy.flow.HeadersHTTP headers for a request or response.
+ + +The canonical API documentation is the code. You can view the API documentation +using pydoc (which is installed with Python by default), like this: + +
+> pydoc libmproxy.flow.Request
+
+ + +## Running scripts on saved flows + +Sometimes, we want to run a script on __Flow__ objects that are already +complete. This happens when you start a script, and then load a saved set of +flows from a file (see the "scripted data transformation" example on the +[mitmdump](@!urlTo("mitmdump.html")!@) page). It also happens when you run a one-shot script on a single flow through the _|_ (pipe) shortcut in mitmproxy. In this case, there are no client connections, and the events are run in the following order: __start__, __request__, __response__, __error__, __done__. If the flow doesn't have a __response__ or __error__ associated with it, the -matching event will be skipped. +matching event will be skipped. + + -- cgit v1.2.3