Server IP : 127.0.0.2 / Your IP : 3.135.236.62 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/requests_toolbelt/adapters/ |
Upload File : |
# -*- coding: utf-8 -*- """ requests_toolbelt.adapters.host_header_ssl ========================================== This file contains an implementation of the HostHeaderSSLAdapter. """ from requests.adapters import HTTPAdapter class HostHeaderSSLAdapter(HTTPAdapter): """ A HTTPS Adapter for Python Requests that sets the hostname for certificate verification based on the Host header. This allows requesting the IP address directly via HTTPS without getting a "hostname doesn't match" exception. Example usage: >>> s.mount('https://', HostHeaderSSLAdapter()) >>> s.get("https://93.184.216.34", headers={"Host": "example.org"}) """ def send(self, request, **kwargs): # HTTP headers are case-insensitive (RFC 7230) host_header = None for header in request.headers: if header.lower() == "host": host_header = request.headers[header] break connection_pool_kwargs = self.poolmanager.connection_pool_kw if host_header: connection_pool_kwargs["assert_hostname"] = host_header elif "assert_hostname" in connection_pool_kwargs: # an assert_hostname from a previous request may have been left connection_pool_kwargs.pop("assert_hostname", None) return super(HostHeaderSSLAdapter, self).send(request, **kwargs)