# Path: coldsweat/fetcher.py
# def fetch_url(url, timeout=10, etag=None, modified_since=None):
#     '''
#     Fecth a given URL optionally issuing a 'Conditional GET' request
#     '''
# 
#     request_headers = {
#         'User-Agent': USER_AGENT
#     }
# 
#     # Conditional GET headers
#     if etag and modified_since:
#         logger.debug(u"fetching %s with a conditional GET (%s %s)" % (url, etag, format_http_datetime(modified_since)))
#         request_headers['If-None-Match'] = etag
#         request_headers['If-Modified-Since'] = format_http_datetime(modified_since)
#         
#     try:
#         response = requests.get(url, timeout=timeout, headers=request_headers)
#     except RequestException, exc:
#         logger.debug(u"tried to fetch %s but got %s" % (url, exc.__class__.__name__))
#         raise exc
#     
#     return response


from requests.exceptions import *
from ..fetcher import fetch_url
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: 

Copyright (c) 2013—2016 Andrea Peltrin
License: MIT (see LICENSE for details)
'''


TEST_FEEDS = (
    (None, 'http://www.aaa.bbb/'),                              # Does not exist
    (200, 'http://www.scripting.com/rss.xml'),                  # First redirect, then 200
    (404, 'http://example.com/wrong-rss.xml'),
)


def run_tests():    
    for expected_status, url in TEST_FEEDS:
        print 'Checking', url, '...'
        try:

# Path: coldsweat/fetcher.py
# def fetch_url(url, timeout=10, etag=None, modified_since=None):
#     '''
#     Fecth a given URL optionally issuing a 'Conditional GET' request
#     '''
# 
#     request_headers = {
#         'User-Agent': USER_AGENT
#     }
# 
#     # Conditional GET headers
#     if etag and modified_since:
#         logger.debug(u"fetching %s with a conditional GET (%s %s)" % (url, etag, format_http_datetime(modified_since)))
#         request_headers['If-None-Match'] = etag
#         request_headers['If-Modified-Since'] = format_http_datetime(modified_since)
#         
#     try:
#         response = requests.get(url, timeout=timeout, headers=request_headers)
#     except RequestException, exc:
#         logger.debug(u"tried to fetch %s but got %s" % (url, exc.__class__.__name__))
#         raise exc
#     
#     return response


# Path: coldsweat/tests/fetcher.py
from requests.exceptions import *
from ..fetcher import fetch_url

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: 

Copyright (c) 2013—2016 Andrea Peltrin
License: MIT (see LICENSE for details)
'''


TEST_FEEDS = (
    (None, 'http://www.aaa.bbb/'),                              # Does not exist
    (200, 'http://www.scripting.com/rss.xml'),                  # First redirect, then 200
    (404, 'http://example.com/wrong-rss.xml'),
)


def run_tests():    
    for expected_status, url in TEST_FEEDS:
        print 'Checking', url, '...'
        try:

            response = fetch_url(url, timeout=5)