# Path: neubot/six.py
# PY3 = sys.version_info[0] == 3
#     MAXSIZE = sys.maxsize
#         MAXSIZE = int((1 << 31) - 1)
#             MAXSIZE = int((1 << 31) - 1)
#             MAXSIZE = int((1 << 63) - 1)
#         class X(object):
# class _LazyDescr(object):
# class MovedModule(_LazyDescr):
# class MovedAttribute(_LazyDescr):
# class _MovedItems(types.ModuleType):
#     class Iterator(object):
#             def __len__(self):
# def _add_doc(func, doc):
# def _import_module(name):
#     def __init__(self, name):
#     def __get__(self, obj, tp):
#     def __init__(self, name, old, new=None):
#     def _resolve(self):
#     def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
#     def _resolve(self):
# def add_move(move):
# def remove_move(name):
#     def advance_iterator(it):
#     def get_unbound_function(unbound):
#     def callable(obj):
#     def get_unbound_function(unbound):
#         def next(self):
# def iterkeys(d):
# def itervalues(d):
# def iteritems(d):
#     def b(s):
#     def u(s):
#         def int2byte(i):
#     def b(s):
#     def u(s):
#     def reraise(tp, value, tb=None):
#     def exec_(code, globs=None, locs=None):
#     def print_(*args, **kwargs):
#         def write(data):
# def with_metaclass(meta, base=object):
#     def buff(string, offset, size=None):
#     def bytes_to_string(octets, encoding):
#     def bytes_to_string_safe(octets, encoding):
#     def buff(string, offset, size=None):
#     def bytes_to_string(octets, encoding):
#     def bytes_to_string_safe(octets, encoding):
# 
# Path: neubot/utils_version.py
# LEGACY_CANONICAL_REPR = "^([0-9]+)\.([0-9]+)(\.([0-9]+))?(-rc([0-9]+))?$"
# CANONICAL_REPR = "^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$"
# NUMERIC_REPR = "^([0-9]+)\.([0-9]{3,3})([0-9]{3,3})([0-9]{3,3})$"
# CANONICAL_VERSION = '0.5.0.0'
# NUMERIC_VERSION = to_numeric(CANONICAL_VERSION)
# PRODUCT = 'Neubot %s' % CANONICAL_VERSION
# HTTP_HEADER = 'Neubot/%s' % CANONICAL_VERSION
# def check(major, minor, patch, rcnum):
# def to_numeric_legacy(string):
# def to_numeric(string):
# def to_canonical(string):
# def compare(left, right):
# def main(args):


import collections
import getopt
import logging
import sys
from neubot.brigade import Brigade
from neubot.handler import Handler
from neubot.poller import POLLER
from neubot.stream import Stream
from neubot import six
from neubot import utils_version
        context = stream.opaque
        if context.body:
            context.body.write(piece)

    def handle_end_of_body(self, stream):
        ''' Handle the END_OF_BODY event '''
        #
        # It is user responsibility to close the stream here
        # if appropriate (i.e. if HTTP/1.0 or if the "Connection"
        # header value is set to  "close").
        #
        context = stream.opaque
        context.handle_line = self._handle_firstline  # Restart

class HttpClientSmpl(HttpClient):
    ''' Simple HTTP client '''

    def handle_connect(self, connector, sock, rtt, sslconfig, extra):
        self.create_stream(sock, self.connection_made, None,
          sslconfig, None, extra)

    def connection_made(self, stream):
        ''' Invoked when the connection is established '''
        context = stream.opaque
        address, port, paths, cntvec = context.extra
        if not paths:
            stream.close()
            return
        self.append_request(stream, 'GET', paths.popleft(), 'HTTP/1.1')
        self.append_header(stream, 'Host', '%s:%s' % (address, port))

# Path: neubot/six.py
# PY3 = sys.version_info[0] == 3
#     MAXSIZE = sys.maxsize
#         MAXSIZE = int((1 << 31) - 1)
#             MAXSIZE = int((1 << 31) - 1)
#             MAXSIZE = int((1 << 63) - 1)
#         class X(object):
# class _LazyDescr(object):
# class MovedModule(_LazyDescr):
# class MovedAttribute(_LazyDescr):
# class _MovedItems(types.ModuleType):
#     class Iterator(object):
#             def __len__(self):
# def _add_doc(func, doc):
# def _import_module(name):
#     def __init__(self, name):
#     def __get__(self, obj, tp):
#     def __init__(self, name, old, new=None):
#     def _resolve(self):
#     def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
#     def _resolve(self):
# def add_move(move):
# def remove_move(name):
#     def advance_iterator(it):
#     def get_unbound_function(unbound):
#     def callable(obj):
#     def get_unbound_function(unbound):
#         def next(self):
# def iterkeys(d):
# def itervalues(d):
# def iteritems(d):
#     def b(s):
#     def u(s):
#         def int2byte(i):
#     def b(s):
#     def u(s):
#     def reraise(tp, value, tb=None):
#     def exec_(code, globs=None, locs=None):
#     def print_(*args, **kwargs):
#         def write(data):
# def with_metaclass(meta, base=object):
#     def buff(string, offset, size=None):
#     def bytes_to_string(octets, encoding):
#     def bytes_to_string_safe(octets, encoding):
#     def buff(string, offset, size=None):
#     def bytes_to_string(octets, encoding):
#     def bytes_to_string_safe(octets, encoding):
# 
# Path: neubot/utils_version.py
# LEGACY_CANONICAL_REPR = "^([0-9]+)\.([0-9]+)(\.([0-9]+))?(-rc([0-9]+))?$"
# CANONICAL_REPR = "^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$"
# NUMERIC_REPR = "^([0-9]+)\.([0-9]{3,3})([0-9]{3,3})([0-9]{3,3})$"
# CANONICAL_VERSION = '0.5.0.0'
# NUMERIC_VERSION = to_numeric(CANONICAL_VERSION)
# PRODUCT = 'Neubot %s' % CANONICAL_VERSION
# HTTP_HEADER = 'Neubot/%s' % CANONICAL_VERSION
# def check(major, minor, patch, rcnum):
# def to_numeric_legacy(string):
# def to_numeric(string):
# def to_canonical(string):
# def compare(left, right):
# def main(args):


# Path: neubot/http_clnt.py
import collections
import getopt
import logging
import sys
from neubot.brigade import Brigade
from neubot.handler import Handler
from neubot.poller import POLLER
from neubot.stream import Stream
from neubot import six
from neubot import utils_version

        context = stream.opaque
        if context.body:
            context.body.write(piece)

    def handle_end_of_body(self, stream):
        ''' Handle the END_OF_BODY event '''
        #
        # It is user responsibility to close the stream here
        # if appropriate (i.e. if HTTP/1.0 or if the "Connection"
        # header value is set to  "close").
        #
        context = stream.opaque
        context.handle_line = self._handle_firstline  # Restart

class HttpClientSmpl(HttpClient):
    ''' Simple HTTP client '''

    def handle_connect(self, connector, sock, rtt, sslconfig, extra):
        self.create_stream(sock, self.connection_made, None,
          sslconfig, None, extra)

    def connection_made(self, stream):
        ''' Invoked when the connection is established '''
        context = stream.opaque
        address, port, paths, cntvec = context.extra
        if not paths:
            stream.close()
            return
        self.append_request(stream, 'GET', paths.popleft(), 'HTTP/1.1')
        self.append_header(stream, 'Host', '%s:%s' % (address, port))

        self.append_header(stream, 'User-Agent', utils_version.HTTP_HEADER)