-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add an optional flag to skip SSL request verification
- Loading branch information
Showing
7 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
package utils | ||
|
||
import ( | ||
"crypto/tls" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
const httpTimeout = 5 * time.Second | ||
|
||
// DoHTTPRequest makes an HTTP request with timeout | ||
func DoHTTPRequest(request *http.Request) (*http.Response, error) { | ||
timeout := time.Duration(httpTimeout) | ||
client := &http.Client{ | ||
Timeout: timeout, | ||
func DoHTTPRequest(request *http.Request, skipSslVerification bool) (*http.Response, error) { | ||
timeout := httpTimeout | ||
var client *http.Client | ||
|
||
if skipSslVerification { | ||
tr := &http.Transport{ | ||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, | ||
} | ||
client = &http.Client{ | ||
Timeout: timeout, | ||
Transport: tr, | ||
} | ||
} else { | ||
client = &http.Client{ | ||
Timeout: timeout, | ||
} | ||
} | ||
return client.Do(request) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters