haruploader¶
The haruploader
module is used for sending har files to a harstorage
instance.
harstorage references:
Run haruploader as standalone script¶
- Args:
- Path to HAR file or directory containing har files to be uploaded.
- Options:
--url
: URL of harstorage instance (default: ‘http://localhost:5000‘)
- Example:
python haruploader.py /path/to/HAR/file.har --url http://127.0.0.1:8000
- For help text:
python haruploader.py -h
Run uploader as part of harprofiler¶
Make sure that harstorage_url is set in the config file, and harprofiler
will run the uploader after it creates the HARs. This will call the upload_hars
method, using as args the har_dir
and harstorage_url
settings provided in the configuration file.
Error handling¶
If the requests lib raises an exception, we will leave the file in the folder to be retried later. The error will still be logged though. These exceptions include the following:
requests.exceptions.ConnectionError requests.exceptions.TooManyRedirects requests.exceptions.Timeout requests.exceptions.HTTPError requests.exceptions.URLRequired
If any other exception is raised while trying to upload the file, the file will be put in another folder, not to be retried. In this case, we assume the cause is a poorly formatted HAR file. The destination folder is titled
failed_uploads
, and will be automatically created as a subdirectory of the folder that the HAR file was originally located.If the file is successfully uploaded, it will be moved to a folder titled
completed_uploads
. Again, this will be automatically created as a subdirectory of the folder that the HAR file was originally located.