Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(14)  |  Call(12)  |  Derive(0)  |  Import(2)

        def split_cgi_response(data):
    headers = []
    prev_n = 0
    while True:
        next_n = data.find('\n', prev_n)
        if next_n < 0:
            break 
        next_line_begin = data[next_n+1:next_n+3]
        headers.append(data[prev_n:next_n].rstrip('\r'))
        if next_line_begin[0] == '\n':
            return headers_dict(headers), data[next_n+2:]
        elif next_line_begin == '\r\n':
            return headers_dict(headers), data[next_n+3:]
        prev_n = next_n+1
    return {}, data
        


src/m/a/MapProxy-1.6.0/mapproxy/test/unit/test_client_cgi.py   MapProxy(Download)
 
from mapproxy.client.http import HTTPClientError
from mapproxy.client.cgi import CGIClient, split_cgi_response
from mapproxy.source import SourceError
 
from nose.tools import eq_
 
class TestSplitHTTPResponse(object):
    def test_n(self):
        eq_(split_cgi_response('header1: foo\nheader2: bar\n\ncontent\n\ncontent'),
    def test_rn(self):
        eq_(split_cgi_response('header1\r\nheader2\r\n\r\ncontent\r\n\r\ncontent'),
            ({'Header1': None, 'Header2': None}, 'content\r\n\r\ncontent'))
    def test_mixed(self):
        eq_(split_cgi_response('header1: bar:foo\r\nheader2\n\r\ncontent\r\n\r\ncontent'),
            ({'Header1': 'bar:foo', 'Header2': None}, 'content\r\n\r\ncontent'))
        eq_(split_cgi_response('header1\r\nheader2\n\ncontent\r\n\r\ncontent'),

src/m/a/mapproxy-HEAD/mapproxy/test/unit/test_client_cgi.py   mapproxy(Download)
 
from mapproxy.client.http import HTTPClientError
from mapproxy.client.cgi import CGIClient, split_cgi_response
from mapproxy.source import SourceError
 
from nose.tools import eq_
 
class TestSplitHTTPResponse(object):
    def test_n(self):
        eq_(split_cgi_response('header1: foo\nheader2: bar\n\ncontent\n\ncontent'),
    def test_rn(self):
        eq_(split_cgi_response('header1\r\nheader2\r\n\r\ncontent\r\n\r\ncontent'),
            ({'Header1': None, 'Header2': None}, 'content\r\n\r\ncontent'))
    def test_mixed(self):
        eq_(split_cgi_response('header1: bar:foo\r\nheader2\n\r\ncontent\r\n\r\ncontent'),
            ({'Header1': 'bar:foo', 'Header2': None}, 'content\r\n\r\ncontent'))
        eq_(split_cgi_response('header1\r\nheader2\n\ncontent\r\n\r\ncontent'),