Î
Îίκος
Hello, i decided am ong other os.environ variables to also grab the
'HTTP_REFERER' fiel but when i try to run my script i was seeing a
KeyError complaining that 'HTTP_REFERER' didnt exist.
So, to see what existed in the os.environ dictionary i issues a print(
os.environ ) to see all available keys and their values:
environ({'SERVER_PORT': '80', 'REQUEST_URI': '/',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch', 'SERVER_ADDR':
'84.200.17.58', 'DOCUMENT_ROOT': '/home/nikos/public_html',
'HTTP_CONNECTION': 'keep-alive', 'SCRIPT_FILENAME':
'/home/nikos/public_html/cgi-bin/metrites.py', 'SERVER_NAME':
'superhost.gr', 'REMOTE_PORT': '58896', 'HTTP_ACCEPT':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.2; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.2
Safari/537.36', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8,el;q=0.6',
'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_HOST': 'superhost.gr',
'REDIRECT_URL': '/index.html', 'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '
Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/1.0.0-fips
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server
at superhost.gr Port 80
\n', 'HTTP_DNT': '1', 'REQUEST_METHOD': 'GET', 'QUERY_STRING':
'file=/home/nikos/public_html/index.html', 'PATH':
'/sbin:/usr/sbin:/bin:/usr/bin', 'HTTP_COOKIE': 'cf_use_ob=0;
__cfduid=da37079bb377f13e9c50224189ab46ac71379783691866;
__utma=210786583.1207352568.1379497319.1380099225.1380108255.32;
__utmc=210786583;
__utmz=210786583.1379497319.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
'REMOTE_ADDR': '176.92.73.41', 'REDIRECT_QUERY_STRING':
'file=/home/nikos/public_html/index.html', 'SERVER_SOFTWARE':
'Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/1.0.0-fips
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635',
'SERVER_ADMIN': '(e-mail address removed)', 'SCRIPT_NAME':
'/cgi-bin/metrites.py', 'REDIRECT_STATUS': '200'})
i dont see anywhere a refferer key so to catch it in a variable sting
like this:
referrer = os.environ['HTTP_REFERER']
Do i miss something? its a suprise to me that the environ dictioanry has
almost anythign but a referrer key.
I need your help please.
'HTTP_REFERER' fiel but when i try to run my script i was seeing a
KeyError complaining that 'HTTP_REFERER' didnt exist.
So, to see what existed in the os.environ dictionary i issues a print(
os.environ ) to see all available keys and their values:
environ({'SERVER_PORT': '80', 'REQUEST_URI': '/',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch', 'SERVER_ADDR':
'84.200.17.58', 'DOCUMENT_ROOT': '/home/nikos/public_html',
'HTTP_CONNECTION': 'keep-alive', 'SCRIPT_FILENAME':
'/home/nikos/public_html/cgi-bin/metrites.py', 'SERVER_NAME':
'superhost.gr', 'REMOTE_PORT': '58896', 'HTTP_ACCEPT':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.2; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.2
Safari/537.36', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8,el;q=0.6',
'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_HOST': 'superhost.gr',
'REDIRECT_URL': '/index.html', 'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '
Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/1.0.0-fips
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server
at superhost.gr Port 80
\n', 'HTTP_DNT': '1', 'REQUEST_METHOD': 'GET', 'QUERY_STRING':
'file=/home/nikos/public_html/index.html', 'PATH':
'/sbin:/usr/sbin:/bin:/usr/bin', 'HTTP_COOKIE': 'cf_use_ob=0;
__cfduid=da37079bb377f13e9c50224189ab46ac71379783691866;
__utma=210786583.1207352568.1379497319.1380099225.1380108255.32;
__utmc=210786583;
__utmz=210786583.1379497319.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
'REMOTE_ADDR': '176.92.73.41', 'REDIRECT_QUERY_STRING':
'file=/home/nikos/public_html/index.html', 'SERVER_SOFTWARE':
'Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/1.0.0-fips
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635',
'SERVER_ADMIN': '(e-mail address removed)', 'SCRIPT_NAME':
'/cgi-bin/metrites.py', 'REDIRECT_STATUS': '200'})
i dont see anywhere a refferer key so to catch it in a variable sting
like this:
referrer = os.environ['HTTP_REFERER']
Do i miss something? its a suprise to me that the environ dictioanry has
almost anythign but a referrer key.
I need your help please.