Tracking Progress of HTTP POST Requests in Go
When sending large files and images via POST requests, developers often face challenges in tracking upload progress. This question explores a reliable method to monitor the progress of such requests in a Go application.
The question suggests manually opening a TCP connection and sending HTTP requests in chunks. However, this approach may encounter limitations with HTTPS sites and is not considered optimal.
The response suggests an alternative solution using a custom io.Reader implementation. By wrapping the actual reader, you can output progress information each time Read is called. The provided example code illustrates how to create a ProgressReader that updates the user as data is sent.
This solution provides a simple and effective way to track the progress of HTTP POST requests in Go, allowing developers to monitor the upload status of large files without relying on manual TCP connections.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3