1515# limitations under the License.
1616#
1717
18+ from __future__ import print_function
19+
1820import logging
1921import requests
2022
2527
2628logger = logging .getLogger (__name__ )
2729
30+ HTTP_INSECURE_MESSAGE = "\n " .join ([
31+ "You have chosen not to verify ssl connections." ,
32+ "This is insecure, but it's your choice." ,
33+ "This has been your single warning." ])
34+
2835
2936def use_admin_auth (func ):
3037
@@ -96,7 +103,7 @@ class HttpMixin(object):
96103
97104 HEADERS = {
98105 'json' : {"content-type" : "application/json" },
99- # 'xml': {"content-type": "application/xml"}
106+ 'xml' : {"content-type" : "application/xml" }
100107 }
101108
102109 def __init__ (self , auth = None , verify = True ):
@@ -106,6 +113,17 @@ def __init__(self, auth=None, verify=True):
106113 }
107114 self ._http_log = logging .getLogger (__name__ )
108115
116+ if not verify :
117+ if self ._http_log .handlers :
118+ self ._http_log .warn (HTTP_INSECURE_MESSAGE )
119+ else :
120+ print (HTTP_INSECURE_MESSAGE )
121+
122+ from requests .packages .urllib3 import disable_warnings
123+ disable_warnings ()
124+
125+
126+
109127 def _request (self , verb , url , quiet = False ,
110128 none_on_404 = False , jsonify = False , raise_for_status = True ,
111129 * args , ** kwargs ):
0 commit comments