This package performs a header injection from API request, where a pair key: value is inserted in the Header.
The user should install the package with the following command:
pip install git+https://github.com/jamesmalmeida/HeIn
Be sure to be using Python 3.10
After installing the package, the user can import the two built-in functions with:
from header_injection import HeaderInjection
from header_injection import TestInjection
The HeaderInjection function is callable, where the argument should be a FastAPI() initialization variable, such as:
app = FastAPI()
HeaderInjection(app)
One can find a demonstration script to run with uvicorn in this git, download the file main.py and run it as:
uvicorn main:app --reload
This should open a local http server to accept the requests.
The TestInjection function performs the actual request, it is callable with two arguments, the first one should be the key and the second one the value, as shown below:
TestInjection('Injected-Key','Injected-Value')
This function will return the whole header, where it can be verified that the new key: value pair will be added.
For now, the code does not accept key and values with spaces.
There is also an example script in this git, refer to the file run-request.py. In this file, you can edit the key and value variables to perform a request.
In addition, there is a run-request-sysarg.py, where the user can simply execute as:
python run-request-sysarg.py Key Value
Thus, one can set the key and values via command line.