Mitmproxy API notes on Httpflow (ii) _mitmproxy

Source: Internet
Author: User
Tags iterable

Class Mitmproxy.flow. Error (msg:str, timestamp = none) → None

An error.

This differs from the protocol error response (for example, HTTP Code 500), which is represented by a generic HttpResponse object. This class is responsible for indicating errors that do not conform to normal protocol communication, such as disconnect, timeout, protocol error.

Reveal the following properties: Msg: A message that describes the error timestamp: The number of seconds since the time get_state ()

Retrieves the state of an object. Set_state (state)

The data returned from the Get_state call loads the object state. HTTP class Mitmproxy.http. HttpRequest (First_line_format, method, scheme, host, port, path, http_version, headers, content, Timestamp_star T = none, Timestamp_end = none, Is_replay = False)

A mitmproxy HTTP request. Classmethod Wrap (Request)

Parcel of an existing mitmproxy.net.http.Request. Anticache ()

Modify this request to remove the header file that might generate a cached response. That is to say, we delete etags and if-modified-since headers. Anticomp ()

Modify this request to remove the header that will compress the resource data. Constrain_encoding ()

The acceptable encoding value is based on the restrictions that we can decode appropriately. Content

HTTP message body (for example, gzip) that is decoded with the content encoding title: ValueError when the content encoding is invalid and strictly true.

See also: Raw_content,text cookies

Request cookies.

An empty Multidictview object if the Cookie Monster eats all of them. Decode (strict = True)

Decodes the body based on the current content-encoding header, and then deletes the header. If there is no content-encoding title, no action is performed. Lift: ValueError When the content encoding is invalid and strictly true. Encode (e)

Encoded with Encoding E, where E is "gzip", "deflate", "identity" or "BR". Any existing content encoding is overwritten and the content is not decoded in advance. Lift: ValueError, when the specified content encoding is invalid. First_line_format

The HTTP request form is defined in RFC7230.

The original form and the asterisk form are categorized as "relative." Get_content (Strict:bool = True) →bytes

HTTP message body (for example, gzip) that is decoded with the content encoding title: ValueError when the content encoding is invalid and strictly true.

See also: Raw_content,text get_text (strict:bool = True) →typing. Union [Str,nonetype]

The HTTP message body decodes using the content encoding header (for example, gzip) and the content Type header character Set. Lift: ValueError When the content encoding or character set is invalid and strict is true.

See also: Content,raw_content headers

Message Header object return: Mitmproxy.net.http.Headers host

The target host. This can be inferred from the original request (for example, from the request line) or from the proxy mode (for example, IP in transparent mode). Get http://example.com/HTTP/1.1

Setting host properties also updates the host header (if present). Host_header

The requested host/authorization header.

This property maps to request.headers["Host" or request.headers[": authority"] depending on whether it is http/1.x or http/2.0. Http_version

Version strings, such as "http/1.1" make (method:str,url:str,content:typing). Union [Bytes,str] = ', headers:typing. Union [Typing. Dict [Str,anystr],typing. iterable [Typing. Tuple [bytes,bytes]]] = ())

A simplified API for creating request objects. Method

HTTP request method, such as "get". Multipart_form

Use multiple-part form data as a Multidictview object. An empty multidict. Multidictview If the content type represents non-form data or the content cannot be resolved.

The key and value are bytes. Path

HTTP request path, such as "/index.html". Make sure to start with a slash, except for the options request that may be just "*". Path_components

The path component of the URL is a string tuple. component is not referenced. Port

Target Port Pretty_host

Similar to host, but uses host headers as an additional preferred data source. This is useful in transparent mode, host only IP address, but may not reflect the actual destination, because the host header may be spoofed. Pretty_url

Prefer URLs, but use pretty_host instead of host. Query

Request a query string as the Multidictview object. Raw_content

RAW (encoded) HTTP message body

See also: Content,text replace (pattern, REPL, flags = 0, count = 0)

Replaces the header, the request path, and the REPL in the request body with the regular expression pattern. The encoded content is decoded before the replacement and then encoded again. Return: The number of replacements. Scheme

HTTP request scenario, should be "http" or "https". Text

The HTTP message body decodes using the content encoding header (for example, gzip) and the content Type header character Set. Lift: ValueError When the content encoding or character set is invalid and strict is true.

See also: Content,raw_content timestamp_end

Last byte timestamp Timestamp_start

First byte timestamp URL

A URL string consisting of the requested URL component Urlencoded_form

URL-encoded form data as a Multidictview object. An empty multidict. Multidictview If the content type represents non-form data or the content cannot be resolved.

Starting with Mitmproxy 1.0, the key and value are strings. Class Mitmproxy.http. HttpResponse (http_version, status_code, Reason, headers, content, Timestamp_start = none, Timestamp_end = None, I S_replay = False)

A Mitmproxy HTTP response. Classmethod Wrap (response)

Parcel of an existing mitmproxy.net.http.Response. Content

HTTP message body (for example, gzip) that is decoded with the content encoding title: ValueError when the content encoding is invalid and strictly true.

See also: Raw_content,text cookies

Respond to cookies. One may be empty multidictview, where the key is a cookie name string and the value is a (value,attr) tuple. The value is a string, and attr is the Multidictview that contains the cookie property. In Attrs, a unary property (for example, HttpOnly) is indicated by a null value. Considerations: Update attr decode (strict = True)

Decodes the body based on the current content-encoding header, and then deletes the header. If there is no content-encoding title, no action is performed. Lift: ValueError When the content encoding is invalid and strictly true. Encode (e)

Encoded with Encoding E, where E is "gzip", "deflate", "identity" or "BR". Any existing content encoding is overwritten and the content is not decoded in advance. Lift: ValueError, when the specified content encoding is invalid. Get_content (Strict:bool = True) →bytes

HTTP message body (for example, gzip) that is decoded with the content encoding title: ValueError when the content encoding is invalid and strictly true.

See also: Raw_content,text get_text (strict:bool = True) →typing. Union [Str,nonetype]

The HTTP message body decodes using the content encoding header (for example, gzip) and the content Type header character Set. Lift: ValueError When the content encoding or character set is invalid and strict is true.

See also: Content,raw_content headers

Message Header object return: Mitmproxy.net.http.Headers http_version

Version strings, such as "http/1.1" make (Status_code:int = 200,content:typing. Union [Bytes,str] = B ', headers:typing. Union [Typing. Dict [Str,anystr],typing. iterable [Typing. Tuple [bytes,bytes]]] = ())

A simplified API for creating response objects. Raw_content

RAW (encoded) HTTP message body

See also: Content,text reason

An HTTP reason phrase, such as "not found". This is always none for the HTTP2 request because the HTTP2 response does not contain a reason phrase. Refresh (now = none)

This fairly complex and heuristic feature refreshes the server response replay. It adjusts the date, expiration, and final modification of the title. It adjusts the cookie expiration. Replace (pattern, REPL, flags = 0, count = 0)

Replaces the header file of the message and the REPL in the body with the regular expression pattern. The encoder will be decoded before the replacement and then encoded again. Return: The number of replacements. Status_code

HTTP status code, for example, 200. Text

The HTTP message body decodes using the content encoding header (for example, gzip) and the content Type header character Set. Lift: ValueError When the content encoding or character set is invalid and strict is true.

See also: Content,raw_content timestamp_end

Last byte timestamp Timestamp_start

First byte timestamp class mitmproxy.http. Httpflow (Client_conn, server_conn, live = None, mode = ' regular ')

Httpflow is a collection of objects representing a single HTTP transaction. Request = None

HttpRequest Purpose response = None

HttpResponse Purpose error = None

Error Purpose

Note that flow can have both a response and an Error object. For example, this may occur when a response is received from the server, but an error occurs when the client is sent back. Server_conn = None

serverconnection Purpose Client_conn = None

Clientconnection Purpose intercepted = None

Is this process currently being intercepted? mode = None

What mode does the agent layer have when it receives this request. Backup (force = False)

Save the backup of this flow to restore the use of the call to. revert (). Intercept ()

Intercept this stream. Processing will stop until the recovery is invoked. Kill ()

Kill the request. Modified ()

Whether the process has been modified. Resume ()

Continue to flow-called after a intercept (). Revert ()

Revert to the last backup state. Replace (pattern, REPL, * args, * * Kwargs)

Replaces the regular expression pattern with REPL in the request and response of the stream. The encoded content is decoded before the replacement and then encoded again.

Returns the number of substitutions made. Record class Mitmproxy.log. Log (Main)

Central logger, exposed to script as Mitmproxy.ctx.log. Debug (TXT)

Log on using level debugging. info (TXT)

Record level information. Alert (TXT)

Record level alerts. Alerts have the same urgency as information, but signal to the interactive tool that the user's attention should be drawn to the output even if the user is not currently viewing the event log. Warn (TXT)

Record level warning. Error (TXT)

Record level error. Class Mitmproxy.log. LogEntry (msg, level)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.