mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-03 10:19:16 +02:00
feat:#52 added lower timeout for http request
This commit is contained in:
@@ -4,14 +4,20 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// getPlanHTML Get the HTML document from the specified URL
|
// getPlanHTML Get the HTML document from the specified URL
|
||||||
|
|
||||||
func GetHTML(url string) (string, error) {
|
func GetHTML(url string) (string, error) {
|
||||||
|
|
||||||
|
// Create HTTP client with timeout of 5 seconds
|
||||||
|
client := http.Client{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
// Send GET request
|
// Send GET request
|
||||||
response, err := http.Get(url)
|
response, err := client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error occurred while making the request: %s\n", err.Error())
|
fmt.Printf("Error occurred while making the request: %s\n", err.Error())
|
||||||
return "", err
|
return "", err
|
||||||
|
Reference in New Issue
Block a user