@@ -47,6 +47,10 @@ module.exports = function (source, options) {
4747 code . push ( indent , '"time"' )
4848 }
4949
50+ if ( opts . insecureSkipVerify ) {
51+ code . push ( indent , '"crypto/tls"' )
52+ }
53+
5054 if ( source . postData . text ) {
5155 code . push ( indent , '"strings"' )
5256 }
@@ -63,14 +67,28 @@ module.exports = function (source, options) {
6367 . blank ( )
6468 }
6569
70+ // Create an insecure transport for the client
71+ if ( opts . insecureSkipVerify ) {
72+ code . push ( indent , 'insecureTransport := http.DefaultTransport.(*http.Transport).Clone()' )
73+ code . push ( indent , 'insecureTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}' )
74+ }
75+
6676 // Create client
6777 let client
68- if ( opts . timeout > 0 ) {
78+ if ( opts . timeout > 0 || opts . insecureSkipVerify ) {
6979 client = 'client'
7080 code . push ( indent , 'client := http.Client{' )
71- . push ( indent + 1 , 'Timeout: time.Duration(%s * time.Second),' , opts . timeout )
72- . push ( indent , '}' )
73- . blank ( )
81+
82+ if ( opts . timeout > 0 ) {
83+ code . push ( indent + 1 , 'Timeout: time.Duration(%s * time.Second),' , opts . timeout )
84+ }
85+
86+ if ( opts . insecureSkipVerify ) {
87+ code . push ( indent + 1 , 'Transport: insecureTransport,' )
88+ }
89+
90+ code . push ( indent , '}' )
91+ code . blank ( )
7492 } else {
7593 client = 'http.DefaultClient'
7694 }
0 commit comments