proxy.plugin.modify_post_data module#

proxy.py#

⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging.

copyright
  1. 2013-present by Abhinav Singh and contributors.

license

BSD, see LICENSE for more details.

class proxy.plugin.modify_post_data.ModifyPostDataPlugin(uid: str, flags: argparse.Namespace, client: proxy.http.connection.HttpClientConnection, event_queue: proxy.core.event.queue.EventQueue, upstream_conn_pool: Optional[UpstreamConnectionPool] = None)[source]#

Bases: proxy.http.proxy.plugin.HttpProxyBasePlugin

Modify POST request body before sending to upstream server.

Following curl executions will work:
  1. Plain curl -v -x localhost:8899 -X POST http://httpbin.org/post -d ‘key=value’

  2. Chunked curl -v -x localhost:8899 -X POST -H ‘Transfer-Encoding: chunked’ http://httpbin.org/post -d ‘key=value’

  3. Chunked & Compressed echo ‘key=value’ | gzip | curl -v -x localhost:8899 -X POST –data-binary @- -H ‘Transfer-Encoding: chunked’ -H ‘Content-Encoding: gzip’ http://httpbin.org/post

MODIFIED_BODY = b'{"key": "modified"}'#
_abc_impl = <_abc._abc_data object>#
before_upstream_connection(request: proxy.http.parser.parser.HttpParser) Optional[proxy.http.parser.parser.HttpParser][source]#

Handler called just before Proxy upstream connection is established.

Return optionally modified request object. If None is returned, upstream connection won’t be established.

Raise HttpRequestRejected or HttpProtocolException directly to drop the connection.

handle_client_request(request: proxy.http.parser.parser.HttpParser) Optional[proxy.http.parser.parser.HttpParser][source]#

Handler called before dispatching client request to upstream.

Note: For pipelined (keep-alive) connections, this handler can be called multiple times, for each request sent to upstream.

Note: If TLS interception is enabled, this handler can be called multiple times if client exchanges multiple requests over same SSL session.

Return optionally modified request object to dispatch to upstream. Return None to drop the request data, e.g. in case a response has already been queued. Raise HttpRequestRejected or HttpProtocolException directly to tear down the connection with client.