lib/cookies.js
function(headers) {
    var cookies = headers['set-cookie']
    if (cookies) {
      cookies.forEach(function(c) {
        var cookiesParams = c.split(';')
        var cookiePair = cookiesParams.shift().split('=')
        var options = {}
        cookiesParams.forEach(function(param) {
          param = param.trim()
          if (param.toLowerCase().indexOf('expires') == 0) {
            var date = param.split('=')[1].trim()
            options.expires = new Date(date)
          }
        })
        this.set(cookiePair[0].trim(), cookiePair[1].trim(), options)
      }.bind(this))
    }
  }
function(headers) {
    var cookies = headers['set-cookie']
    if (cookies) {
      cookies.forEach(function(c) {
        var cookiesParams = c.split(';')
        var cookiePair = cookiesParams.shift().split('=')
        var options = {}
        cookiesParams.forEach(function(param) {
          param = param.trim()
          if (param.toLowerCase().indexOf('expires') == 0) {
            var date = param.split('=')[1].trim()
            options.expires = new Date(date)
          }
        })
        this.set(cookiePair[0].trim(), cookiePair[1].trim(), options)
      }.bind(this))
    }
  }
function ( headers ) { var cookies = headers [ 'set-cookie' ] if ( cookies ) { cookies . forEach ( function ( c ) { var cookiesParams = c . split ( ';' ) var cookiePair = cookiesParams . shift ( ) . split ( '=' ) var options = { } cookiesParams . forEach ( function ( param ) { param = param . trim ( ) if ( param . toLowerCase ( ) . indexOf ( 'expires' ) == 0 ) { var date = param . split ( '=' ) [ 1 ] . trim ( ) options . expires = new Date ( date ) } } ) this . set ( cookiePair [ 0 ] . trim ( ) , cookiePair [ 1 ] . trim ( ) , options ) } . bind ( this ) ) } }
Parses headers from server's response for 'set-cookie' header and store cookie's values.
Also parses expiration date
@param headers
Parses headers from server s response for set - cookie header and store cookie s values . Also parses expiration date