DR695H | ae6fedd | 2019-05-01 18:52:33 -0400 | [diff] [blame] | 1 | from six.moves.urllib.parse import urlparse |
DR695H | 8ad8542 | 2019-05-03 11:41:14 -0400 | [diff] [blame] | 2 | from six.moves import urllib |
DR695H | ae6fedd | 2019-05-01 18:52:33 -0400 | [diff] [blame] | 3 | |
DR695H | 861eba5 | 2018-02-23 16:42:59 -0500 | [diff] [blame] | 4 | import urllib3 |
DR695H | ae6fedd | 2019-05-01 18:52:33 -0400 | [diff] [blame] | 5 | |
DR695H | 5fa0146 | 2017-02-15 18:21:12 -0500 | [diff] [blame] | 6 | |
| 7 | class HTTPUtils: |
| 8 | """HTTPUtils is common resource for simple http helper keywords.""" |
Jerry Flood | 96e3d06 | 2017-04-21 16:32:33 -0400 | [diff] [blame] | 9 | |
DR695H | 5fa0146 | 2017-02-15 18:21:12 -0500 | [diff] [blame] | 10 | def url_encode_string(self, barestring): |
kaihlavi | 0932c69 | 2019-06-06 11:08:57 +0300 | [diff] [blame] | 11 | """URL Encode String takes in a string and converts it into fully 'percent-encoded' string""" |
| 12 | return urllib.parse.quote(barestring) |
Jerry Flood | 96e3d06 | 2017-04-21 16:32:33 -0400 | [diff] [blame] | 13 | |
| 14 | def disable_warnings(self): |
kaihlavi | 0932c69 | 2019-06-06 11:08:57 +0300 | [diff] [blame] | 15 | """ Disable all warnings when creating sessions """ |
Jerry Flood | 9e09020 | 2017-10-27 08:29:25 -0400 | [diff] [blame] | 16 | urllib3.disable_warnings() |
| 17 | |
| 18 | def url_parse(self, url): |
DR695H | 861eba5 | 2018-02-23 16:42:59 -0500 | [diff] [blame] | 19 | """ Get pieces of the URL """ |
DR695H | 8ad8542 | 2019-05-03 11:41:14 -0400 | [diff] [blame] | 20 | return urlparse(url) |