Skip to content

Commit

Permalink
Allow headers sent out by proxy to be modified from the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
nibrahim committed May 9, 2012
1 parent d70f74b commit 581f0a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions config.yml
Expand Up @@ -5,6 +5,10 @@ storage:
max_file_size: 100000000 # 100MB approx.
pattern: "liveweb-%(seq)s-%(timestamp)s.arc.gz"

extra_headers:
Connection: "keep-alive"


user_agent: "ia_archiver(OS-Wayback)"

# Max size of ARC record that can be stored in cache
Expand All @@ -22,3 +26,5 @@ timeout: 1

#cache:
# type: redis

# Extra headers which will be sent by the proxy to the remote site.
8 changes: 6 additions & 2 deletions liveweb/config.py
Expand Up @@ -7,14 +7,15 @@
import logging

user_agent = "ia_archiver(OS-Wayback)"
extra_headers = {}

M = 1024 * 1024

# Max size of ARC record that can be stored in cache
max_cacheable_size = 10 * M

# timeout in seconds
timeout = 60
timeout = 600

dns_timeout = None
connect_timeout = None
Expand Down Expand Up @@ -68,9 +69,12 @@ def load(filename):
return

d = yaml.safe_load(open(filename))


print 'Here', d
if "max_cacheable_size" in d:
d['max_cacheable_size'] = _parse_size(d['max_cacheable_size'])



# update config
globals().update(d)
Expand Down
7 changes: 3 additions & 4 deletions liveweb/proxy.py
Expand Up @@ -132,10 +132,9 @@ def _urlopen(url):
Called by urlopen and test cases.
"""
headers = {
"User-Agent": config.user_agent,
"Connection": "close"
}
headers = config.get("extra_headers",{})
headers['User-Agent'] = config.user_agent

type, host, selector = split_type_host(url)

conn = ProxyHTTPConnection(host, url=url)
Expand Down

0 comments on commit 581f0a4

Please sign in to comment.