HttpHelper (VB.NET)

A comprehensive guide to the HttpHelper (VB.NET)

HttpHelper (VB.NET)

A comprehensive utility class for making HTTP requests and handling responses, with support for various HTTP methods, authentication, and data formats.

Features

Installation

Add the HttpHelper.vb file to your project.

Imports JVR.Helpers

Usage Examples

Basic HTTP Requests

Dim http As New HttpHelper()

' GET request
Dim response As String = Await http.GetAsync("https://api.example.com/data")

' POST request with JSON
Dim data = New With {.name = "John", .age = 30}
Dim response As String = Await http.PostJsonAsync("https://api.example.com/users", data)

' PUT request with form data
Dim formData As New Dictionary(Of String, String) From {{"key", "value"}}
Dim response As String = Await http.PutFormAsync("https://api.example.com/update", formData)

Authentication

Dim http As New HttpHelper()

' Basic authentication
http.SetBasicAuth("username", "password")

' Bearer token
http.SetBearerToken("your-token-here")

' Custom headers
http.AddHeader("API-Key", "your-api-key")

Advanced Features

Dim http As New HttpHelper()

' Configure retry policy
http.ConfigureRetry(maxAttempts:=3, retryDelay:=TimeSpan.FromSeconds(1))

' Set timeout
http.SetTimeout(TimeSpan.FromSeconds(30))

' Download file
Await http.DownloadFileAsync("https://example.com/file.pdf", "local-file.pdf")

API Reference

HTTP Methods

JSON Operations

Form Data

Configuration

Response Handling

Dependencies

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Version History

Legal Disclaimer

This documentation and associated helper scripts are provided "as is" without warranty of any kind, either express or implied.

  1. The code examples and helper functions are for illustrative purposes only.
  2. Users should thoroughly test any implementation in their specific environment.
  3. The authors are not responsible for any issues or damages arising from the use of these scripts.
  4. Always follow security best practices and your organization's coding guidelines.