otupy.transfers.http.message.Message
- class Message(headers: Headers = None, body: Body = None, signature: str = None)
Bases:
RecordHTTP Message representation
This class implements the HTTP-specific representation of the OpenC2 Message metadata. The OpenC2 Message metadata are described in Table 3.1 of the Language Specification as message elements, but they are not framed in a concrete structure. The HTTP Specification defines such structure in Sec. 3.3.2, and this class is its implementation.
The methods of this class are meant to translate back and for the otupy Message class.
Methods
Builds instance from dictionary
Create an otupy Message from HTTP Message
Create HTTP Message from otupy Message
Converts to dictionary
Attributes
Contains the Content
Contains the Message metadata
Not used (the Specification does not define its usage
- classmethod fromdict(dic, e)
Builds instance from dictionary
It is used during deserialization to create an otupy instance from the text message. It takes an
Encoderinstance that is used to recursively build instances of the inner objects (theEncoderprovides standard methods to create instances of base objects like strings, integers, boolean).- Parameters:
dic – The intermediary dictionary representation from which the object is built.
e – The
Encoderthat is being used.
- Returns:
An instance of this class initialized from the dictionary values.
- get()
Create an otupy Message from HTTP Message
- Parameters:
msg – An otupy Message.
- Returns:
An HTTP Message
- set(msg: Message)
Create HTTP Message from otupy Message
- Parameters:
msg – An otupy Message.
- Returns:
An HTTP Message
- todict(e)
Converts to dictionary
It is used to convert this object to an intermediary representation during serialization. It takes an
Encoderargument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat is being used.- Returns:
A dictionary compliants to the Language Specification’s serialization rules.