Parse cookie data from a text file in HTTP header format.

    @return: list of tuples (headers, scheme, host, path)
433739
def from_file (filename):
    
    entries = []
    with open(filename) as fd:
        lines = []
        for line in fd.readlines():
            line = line.rstrip()
            if not line:
                if lines:
                    entries.append(from_headers("\r\n".join(lines)))
                lines = []
            else:
                lines.append(line)
        if lines:
            entries.append(from_headers("\r\n".join(lines)))
        return entries
101884
def cookies(self):
    
    return [line.strip()
            for line in self.conn.issue_command("GetCookies").split("\n")
            if line.strip()]
79840
def parse_cookie(self, string):
        '''
        
        '''
        results = re.findall('([^=]+)=([^\;]+);?\s?', string)
        my_dict = {}
        for item in results:
            my_dict[item[0]] = item[1]

        return my_dict
667122
def build_headers(self):
        '''
        
        '''
        if not 'Content-Type' in self.headers:
            content_type = self.content_type
            if self.encoding != DEFAULT_ENCODING:
                content_type += '; charset=%s' % self.encoding
            self.headers['Content-Type'] = content_type

        headers = list(self.headers.items())
        # Append cookies
        headers += [
            ('Set-Cookie', cookie.OutputString())
            for cookie in self.cookies.values()
        ]
        return headers
134997
def _parse_header(self, data):
        
        return_list = []

        headers = data.split(':')

        for header in headers:
            header = re.split(' IN ', header, flags=re.I) # ignore case
            xheader = {'name': header[0].strip()}
            if len(header) > 1:
                xheader['units'] = header[1].strip()
            return_list.append(xheader)

        return return_list
406214
def curl(self):
        
        ret = 'curl -X %s ' % self.method
        ret += self.url
        if self.request_data:
            ret += " -d '%s'" % json.dumps(self.request_data)
        if self.headers:
            ret += ''.join(
                [' -H "%s: %s"' % (k, v) for k, v in self.headers.items()])
        if self.cookies:
            ret += ' --cookie "%s"' % (
                '&'.join(['%s=%s' % (k, v) for k, v in self.cookies.items()]),)
        return ret
392292
private static Map<String, String> extractDataFromCookie(String cookieValue) {
		HashMap<String, String> data = new HashMap<String, String>();
		String[] fields = cookieValue.split("\\&");
		for (String field : fields) {
			String[] keyValue = field.split("\\=");
			try {
				data.put(keyValue[0], URLDecoder.decode(keyValue[1], "UTF-8"));
			} catch (UnsupportedEncodingException wontHappen) {
			}
		}
		return data;
	}
201774
def getHeaders(self):
        '''
        
        '''
        items = self.data
        headers = {}
        for item in items:
            if len(item) > 0 and self._judeNOtIn(item, ['curl', 'GET', 'Cookie', 'cookie']):
                sp = item.split(':')
                headers[sp[0]] = sp[1]
        return headers
1198921
def parse_headers(self, http_code):
		
		if self.__ro_flag:
			raise RuntimeError('Read-only object changing attempt')
		self.__headers = WHTTPHeaders.import_headers(http_code)
1290936
def parse_cookies(self, req, name, field):
        """"""
        return core.get_value(req.cookies, name, field)
647765
def get_http_header(self) -> Response:
        '''
        '''
        with wpull.util.reset_file_offset(self.block_file):
            data = self.block_file.read(4096)

        match = re.match(br'(.*?\r?\n\r?\n)', data)

        if not match:
            return

        status_line, dummy, field_str = match.group(1).partition(b'\n')

        try:
            version, code, reason = Response.parse_status_line(status_line)
        except ValueError:
            return

        response = Response(status_code=code, reason=reason, version=version)

        try:
            response.fields.parse(field_str, strict=False)
        except ValueError:
            return

        return response
1254611
def COOKIES(self):
        
        raw_dict = SimpleCookie(self.headers.get('Cookie',''))
        cookies = {}
        for cookie in six.itervalues(raw_dict):
            cookies[cookie.key] = cookie.value
        return cookies
539418
public static Cookie[] parseCookieHeader( String header ) {

        if ((header == null) || (header.length() < 1)) {
            return (new Cookie[0]);
        }

        ArrayList<Cookie> cookies = new ArrayList<Cookie>();
        while (header.length() > 0) {
            int semicolon = header.indexOf(';');
            if (semicolon < 0) {
                semicolon = header.length();
            }
            if (semicolon == 0) {
                break;
            }
            String token = header.substring(0, semicolon);
            if (semicolon < header.length()) {
                header = header.substring(semicolon + 1);
            } else {
                header = "";
            }
            try {
                int equals = token.indexOf('=');
                if (equals > 0) {
                    String name = token.substring(0, equals).trim();
                    String value = token.substring(equals + 1).trim();
                    cookies.add(new Cookie(name, value));
                }
            } catch (Throwable e) {
                // do nothing ?!
            }
        }

        return cookies.toArray(new Cookie[cookies.size()]);
    }
113232
private function parse($headers)
    {
        foreach (preg_split('/\r\n|\r|\n/', $headers) as $i => $line) {
            if ($i === 0) {
                $this->headers['http_code'] = $line;
            } else {
                list($key, $value) = explode(': ', $line);

                if ($key === 'Set-Cookie') {
                    list($textCookie) = explode(';', $value);
                    list($cookieKey, $cookieValue) = explode('=', $textCookie);

                    $this->cookies[$cookieKey] = $cookieValue;
                } else {
                    $this->headers[$key] = $value;
                }
            }
        }
    }
1129864
def parse_cookies(self, req: Request, name: str, field: Field) -> typing.Any:
        """"""
        return core.get_value(req.cookies, name, field)
290974
def _extract_cookies(self, response: Response):
        ''''''
        self._cookie_jar.extract_cookies(
            response, response.request, self._get_cookie_referrer_host()
        )
334524
def _get_headers(self, environ):
        
        headers = self.headers
        method = environ['REQUEST_METHOD']

        if has_empty_content(self.status_code, method) and method != HEAD:
            headers.pop('content-type', None)
            headers.pop('content-length', None)
            self._content = ()
        else:
            if not self.is_streamed():
                cl = reduce(count_len, self._content, 0)
                headers['content-length'] = str(cl)
            ct = headers.get('content-type')
            # content type encoding available
            if self.encoding:
                ct = ct or 'text/plain'
                if ';' not in ct:
                    ct = '%s; charset=%s' % (ct, self.encoding)
            if ct:
                headers['content-type'] = ct
            if method == HEAD:
                self._content = ()
        # Cookies
        if (self.status_code < 400 and self._can_store_cookies and
                self._cookies):
            for c in self.cookies.values():
                headers.add('set-cookie', c.OutputString())
        return headers.items()