Parses the incoming bytestream as a URL encoded form,
        and returns the resulting QueryDict.
424915
def parse(self, stream, media_type=None, parser_context=None):
        
        parser_context = parser_context or {}
        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
        data = QueryDict(stream.read(), encoding=encoding)
        return data
621662
def parse(self, data: bytes, context=None):
        
        stream = BytesIO(data)
        return self.parse_stream(stream, context)
609053
def parse(cls, uri):
		
		uri_components = urlsplit(uri)
		adapter_fn = lambda x: x if x is not None and (isinstance(x, str) is False or len(x)) > 0 else None

		return cls(
			scheme=adapter_fn(uri_components.scheme),
			username=adapter_fn(uri_components.username),
			password=adapter_fn(uri_components.password),
			hostname=adapter_fn(uri_components.hostname),
			port=adapter_fn(uri_components.port),
			path=adapter_fn(uri_components.path),
			query=adapter_fn(uri_components.query),
			fragment=adapter_fn(uri_components.fragment),
		)
673708
def _grabContentFromUrl(self, url):
        
        # Defining an empty object for the response
        info = {}
                
        # This part has to be modified...        
        try:            
            # Configuring the socket
            queryURL = "http://" + self.info["host"] + ":" + self.info["port"] + "/" + url
            response = urllib2.urlopen(queryURL)

            # Rebuilding data to be processed
            data = str(response.headers) + "\n"

            data += response.read()

            # Processing data as expected
            info = self._createDataStructure(data)     
            
        # Try to make the errors clear for other users
        except Exception, e:
            errMsg = "ERROR Exception. Something seems to be wrong with the Zeronet Bundler."   
            raise Exception( errMsg + " " + str(e))        
            
        return info
313092
def _make_canonical_query_string(parsed):
    
    query_params = urlparse.parse_qs(parsed.query, keep_blank_values=True)
    sorted_query_params = sorted((k, v)
                                 for k, vs in query_params.items()
                                 for v in vs)
    return urllib.urlencode(sorted_query_params)
317945
def parse_querystring(self, req, name, field):
        """"""
        return core.get_value(req.query, name, field)
749239
def from_url(cls, url, show_host=True):
        ''''''
        # url must be idna-encoded and url-quotted

        if six.PY2:
            if isinstance(url, six.text_type):
                url = url.encode('utf-8')
            parsed = urlparse(url)
            netloc = parsed.netloc.decode('utf-8') # XXX HACK
        else:# pragma: no cover
            if isinstance(url, six.binary_type):
                url = url.decode('utf-8', errors='replace') # XXX
            parsed = urlparse(url)
            netloc = parsed.netloc

        query = _parse_qs(parsed.query)
        host = netloc.split(':', 1)[0] if ':' in netloc else netloc

        port = netloc.split(':')[1] if ':' in netloc else ''
        path = unquote(parsed.path)
        fragment = unquote(parsed.fragment)
        if not fragment and not url.endswith('#'):
            fragment = None
        return cls(path,
                   query, host,
                   port, parsed.scheme, fragment, show_host)
938392
def parse_querystring(querystring):
    
    if querystring is None or len(querystring) == 0:
        return {}

    qs_dict = parse.parse_qs(querystring, keep_blank_values=True)
    for key in qs_dict:
        if len(qs_dict[key]) != 1:
            continue
        qs_dict[key] = qs_dict[key][0]
        if qs_dict[key] == '':
            qs_dict[key] = True

    return dict((key, qs_dict[key]) for key in qs_dict if len(key) != 0)
1144933
def stream(self, url, params=None, chunk_size=64*1024):
        ''
        r = self.request(url, params=params)
        for chunk in r.iter_content(chunk_size):
            yield chunk
1107657
def decode(self, byteStream):
        """"""
        self.header = bytearray(byteStream[:HEADER_SIZE])
        self.payload = byteStream[HEADER_SIZE:]
504479
def parse_url(url):
    
    try:
        url = unicode(url)
    except UnicodeDecodeError:
        pass

    if py3k:
        make_utf8 = lambda x: x
    else:
        make_utf8 = lambda x: isinstance(x, unicode) and x.encode('utf-8') or x

    if '://' in url:
        scheme, url = url.split('://', 1)
    else:
        scheme = 'http'
    url = 'http://' + url
    parsed = urlparse.urlsplit(url)
    r = ObjectDict()
    r['scheme'] = make_utf8(scheme)
    r['netloc'] = make_utf8(parsed.netloc)
    r['path'] = make_utf8(parsed.path)
    r['query'] = make_utf8(parsed.query)
    r['fragment'] = make_utf8(parsed.fragment)
    r['uri'] = make_utf8(parsed.path)
    if parsed.query:
        r['uri'] += '?' + make_utf8(parsed.query)
    r['username'] = make_utf8(parsed.username)
    r['password'] = make_utf8(parsed.password)
    host = make_utf8(parsed.hostname.encode('idna').decode('utf-8'))
    r['host'] = r['hostname'] = host
    try:
        r['port'] = parsed.port
    except ValueError:
        r['port'] = None
    if r['port']:
        r['http_host'] = '%s:%d' % (r['host'], r['port'])
    else:
        r['http_host'] = r['host']

    return r
35782
def _get_data(url):
    """"""
    if urllib_parse.urlparse(url).scheme in ('http', 'https'):
        resp = urllib_request.urlopen(url)
        encoding = resp.headers.get('content-encoding', 'plain')
        data = resp.read()
        if encoding == 'plain':
            data = data.decode('utf-8')
        elif encoding == 'gzip':
            data = BytesIO(data)
            data = gzip.GzipFile(fileobj=data).read().decode('utf-8')
        else:
            raise RuntimeError('unknown encoding')
    else:
        with codecs.open(url, mode='r', encoding='utf-8') as fid:
            data = fid.read()

    return data
41966
def _decode_request(self, encoded_request):
        """"""
        obj = self.serializer.loads(encoded_request)
        return request_from_dict(obj, self.spider)
1069015
def from_url(cls, url, filename=None, chunk_size=CHUNK_SIZE):
        
        pipe = _WebPipe(url, chunk_size=chunk_size)
        if filename is None:
            filename = pipe.name

        return cls(pipe, filename, chunk_size)
433713
private String readResponseStream(InputStream responseStream, HttpURLConnection connection)
            throws IOException {
        LOGGER.debug("Reading response stream");
        InputStream decodedStream = responseStream;
        if (compression == Compression.LZF && "lzf".equals(connection.getHeaderField("Content-Encoding"))) {
            LOGGER.debug("Decoding lzf");
            decodedStream = new LZFInputStream(responseStream);
        }

        int contentLength = connection.getContentLength();

        if (contentLength == 0) {
            return "";
        } else {
            return new String(ByteStreams.toByteArray(decodedStream), UTF_8);
        }
    }
591893
def parse_url(url):
    
    parsed = urlparse(url)
    kwargs = parse_qsl(parsed.query)

    # TCP redis connection
    if parsed.scheme == 'redis':
        details = {'host': parsed.hostname}
        if parsed.port:
            details['port'] = parsed.port
        if parsed.password:
            details['password'] = parsed.password
        db = parsed.path.lstrip('/')
        if db and db.isdigit():
            details['db'] = db

    # Unix socket redis connection
    elif parsed.scheme == 'redis+socket':
        details = {'unix_socket_path': parsed.path}
    else:
        raise ValueError('Unsupported protocol %s' % (parsed.scheme))

    # Add kwargs to the details and convert them to the appropriate type, if needed
    details.update(kwargs)
    if 'socket_timeout' in details:
        details['socket_timeout'] = float(details['socket_timeout'])
    if 'db' in details:
        details['db'] = int(details['db'])

    return details
867612
def _parse(self):
        
        stream = self.stream
        media_type = self.content_type

        if stream is None or media_type is None:
            empty_data = QueryDict('', encoding=self._request._encoding)
            empty_files = MultiValueDict()
            return (empty_data, empty_files)

        parser = self.negotiator.select_parser(self, self.parsers)

        if not parser:
            raise exceptions.UnsupportedMediaType(media_type)

        try:
            parsed = parser.parse(stream, media_type, self.parser_context)
        except:
            # If we get an exception during parsing, fill in empty data and
            # re-raise.  Ensures we don't simply repeat the error when
            # attempting to render the browsable renderer response, or when
            # logging the request or similar.
            self._data = QueryDict('', encoding=self._request._encoding)
            self._files = MultiValueDict()
            self._full_data = self._data
            raise

        # Parser classes may return the raw data, or a
        # DataAndFiles object.  Unpack the result as required.
        try:
            return (parsed.data, parsed.files)
        except AttributeError:
            empty_files = MultiValueDict()
            return (parsed, empty_files)