Makes a string of cookie keys and values.
    Can be used to set a Cookie header.
178485
def make_cookie_values(cj, class_name):
    
    path = "/" + class_name

    cookies = [c.name + '=' + c.value
               for c in cj
               if c.domain == "class.coursera.org"
               and c.path == path]

    return '; '.join(cookies)
1294416
def cookietostr(self):
        ""
        self.cookies = dict((k, (v.decode(self.encoding) if not isinstance(v, str) else v)) for k,v in self.cookies.items())
        return self.cookies
992331
def format_headers
      @headers.stringify_keys.each_with_object({}) do |key_with_value, headers|
        headers[format_key(key_with_value.first)] = key_with_value.last
      end
    end
692743
def add_cookie(self, key, value, **attrs):
        '''
        
        '''
        if attrs:
            c = Morsel()
            c.set(key, value, **attrs)
            self.cookies[key] = c
        else:
            self.cookies[key] = value
1243571
def headerlist(self):
        '''  '''
        out = []
        headers = list(self._headers.items())
        if 'Content-Type' not in self._headers:
            headers.append(('Content-Type', [self.default_content_type]))
        if self._status_code in self.bad_headers:
            bad_headers = self.bad_headers[self._status_code]
            headers = [h for h in headers if h[0] not in bad_headers]
        out += [(name, val) for name, vals in headers for val in vals]
        if self._cookies:
            for c in self._cookies.values():
                out.append(('Set-Cookie', c.OutputString()))
        return out
611365
public function configureCookie()
    {
        $settingFields = ['expires', 'path', 'domain', 'secure', 'key', 'httpOnly', 'encryption'];
        $settings = $this->config('settings');
        $cookieKey = $this->config('cookieKey');
        foreach ($settingFields as $field) {
            if (isset($settings[$field])) {
                $this->Cookie->configKey($cookieKey, $field, $settings[$field]);
            }
        }
    }
1312398
function createJWPCookie (key, cookieString, converter = null) {
  let result = {};
  let cookies = cookieString ? cookieString.split('; ') : [];
  for (let cookie of cookies) {
    let parts = cookie.split('=');

    // get the first and second element as name and value
    let name = decodeURIComponent(parts.shift());
    let val = parts[0];

    // if name is key, this is the central element of the cookie, so add as `name`
    // otherwise it is an optional element
    if (key && key === name) {
      result.name = key;
      result.value = convertCookie(val, converter);
    } else {
      result[name] = convertCookie(val, converter);
    }
  }
  return result;
}
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()]);
    }
1200518
def append_cookie(self, cookie, name, payload, typ, domain=None, path=None,
                      timestamp="", max_age=0):
        
        timestamp = str(int(time.time()))

        # create cookie payload
        try:
            _payload = "::".join([payload, timestamp, typ])
        except TypeError:
            _payload = "::".join([payload[0], timestamp, typ])

        content = make_cookie_content(name, _payload, self.sign_key, domain=domain,
                                      path=path, timestamp=timestamp,
                                      enc_key=self.enc_key, max_age=max_age,
                                      sign_alg=self.sign_alg)

        for name, args in content.items():
            cookie[name] = args['value']
            for key, value in args.items():
                if key == 'value':
                    continue
                cookie[name][key] = value

        return cookie
147302
def _prepare_headers(
            self,
            headers: Optional[LooseHeaders]) -> 'CIMultiDict[str]':
        
        # Convert headers to MultiDict
        result = CIMultiDict(self._default_headers)
        if headers:
            if not isinstance(headers, (MultiDictProxy, MultiDict)):
                headers = CIMultiDict(headers)
            added_names = set()  # type: Set[str]
            for key, value in headers.items():
                if key in added_names:
                    result.add(key, value)
                else:
                    result[key] = value
                    added_names.add(key)
        return result
428188
def from_headers (strheader):
    
    res = []
    fp = StringIO(strheader)
    headers = httplib.HTTPMessage(fp, seekable=True)
    if "Host" not in headers:
        raise ValueError("Required header 'Host:' missing")
    host = headers["Host"]
    path= headers.get("Path", "/")
    for header in headers.getallmatchingheaders("Set-Cookie"):
        headervalue = header.split(':', 1)[1]
        for pairs in cookielib.split_header_words([headervalue]):
            for name, value in pairs:
                cookie = requests.cookies.create_cookie(name, value,
                    domain=host, path=path)
                res.append(cookie)
    return res
1309829
def string_keys(hash={})
      hash.inject({}) do |options, (key, value)|
        options[key.to_s] = value
        options
      end
    end
219854
function createJSCookie (key, value, options = {}) {
  return [
    encodeURIComponent(key), '=', value,
    options.expires
      ? `; expires=${options.expires}`
      : '',
    options.path
      ? `; path=${options.path}`
      : '',
    options.domain
      ? `; domain=${options.domain}`
      : '',
    options.secure
      ? '; secure'
      : ''
  ].join('');
}
1011766
def cookie_encode(data, key):
    '''  '''
    msg = base64.b64encode(pickle.dumps(data, -1))
    sig = base64.b64encode(hmac.new(tob(key), msg).digest())
    return tob('!') + sig + tob('?') + msg
340109
def __toString(self, values):
		
		for key in values:
			if not values[key] is str:
				values[key] = str(values[key])
		return values
144529
def set_cookie(  # type: ignore
            self,
            key: str,
            value: AnyStr='',
            max_age: Optional[Union[int, timedelta]]=None,
            expires: Optional[datetime]=None,
            path: str='/',
            domain: Optional[str]=None,
            secure: bool=False,
            httponly: bool=False,
    ) -> None:
        
        if isinstance(value, bytes):
            value = value.decode()  # type: ignore
        cookie = create_cookie(key, value, max_age, expires, path, domain, secure, httponly)  # type: ignore  # noqa: E501
        self.headers.add('Set-Cookie', cookie.output(header=''))
48785
function(type, key, flag) {
			key = "" + key; // #90
			var local = this._local,
				instOpts = this.options.persist,
				delim = instOpts.cookieDelimiter,
				cookieName = local.cookiePrefix + type,
				data = local._data(cookieName),
				keyList = data ? data.split(delim) : [],
				idx = $.inArray(key, keyList);
			// Remove, even if we add a key,  so the key is always the last entry
			if (idx >= 0) {
				keyList.splice(idx, 1);
			}
			// Append key to cookie
			if (flag) {
				keyList.push(key);
			}
			local._data(cookieName, keyList.join(delim));
		}