mrequests easy HTTP client library
Posted: Tue May 04, 2021 5:36 pm
Hi all,
in the past I've often seen users struggle with urequests from micropython-lib, because it lacks many features often needed when making HTTP requests or is inconvenient to use, and PRs trying to improve it have been ignored for years.
So now I finally consolidated all the different versions of urequests with different improvements I made for various projects and created a new, evolved version, which I call mrequests and which is now part of my collection of MicroPython modules called micropyton-stm-lib:
https://github.com/SpotlightKid/micropython-stm-lib
(Despite the name, most modules in this lib work with all (or at least several ports) of MicroPython, not just the stm32 port. It's a historical thing.)
I hope that mrequests helps making the most common use cases for retrieving things via HTTP/HTTPS or using HTTP APIs easier. Here are some of its additional features over urequests:
* Supports unix*, stm32*+, esp8266* and esp32 port as well as CPython
* Supports HTTP basic auth.
* Supports redirection with absolute and relative URLs.
* Response headers can optionally be saved in the response object.
* Support for responses with chunked transfer encoding.
* Response objects have a save method to save the response body to a file.
* More lenient handling of mixed str/bytes objects in request data and headers.
* SSL support with limitations due to problems with MicroPython's ssl module on these ports.
+ With custom-compiled firmware with network/ssl support.
Please see the README file in the mrequests directory of the repository for more information.
The repository also has a small collection of example scripts, which I plan to enlarge.
Share & Enjoy!
Chris
in the past I've often seen users struggle with urequests from micropython-lib, because it lacks many features often needed when making HTTP requests or is inconvenient to use, and PRs trying to improve it have been ignored for years.
So now I finally consolidated all the different versions of urequests with different improvements I made for various projects and created a new, evolved version, which I call mrequests and which is now part of my collection of MicroPython modules called micropyton-stm-lib:
https://github.com/SpotlightKid/micropython-stm-lib
(Despite the name, most modules in this lib work with all (or at least several ports) of MicroPython, not just the stm32 port. It's a historical thing.)
I hope that mrequests helps making the most common use cases for retrieving things via HTTP/HTTPS or using HTTP APIs easier. Here are some of its additional features over urequests:
* Supports unix*, stm32*+, esp8266* and esp32 port as well as CPython
* Supports HTTP basic auth.
* Supports redirection with absolute and relative URLs.
* Response headers can optionally be saved in the response object.
* Support for responses with chunked transfer encoding.
* Response objects have a save method to save the response body to a file.
* More lenient handling of mixed str/bytes objects in request data and headers.
* SSL support with limitations due to problems with MicroPython's ssl module on these ports.
+ With custom-compiled firmware with network/ssl support.
Please see the README file in the mrequests directory of the repository for more information.
The repository also has a small collection of example scripts, which I plan to enlarge.
Share & Enjoy!
Chris