Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

getResponseHeaders should return a list of values #13

Closed
aagahi opened this issue Jan 4, 2013 · 1 comment
Closed

getResponseHeaders should return a list of values #13

aagahi opened this issue Jan 4, 2013 · 1 comment

Comments

@aagahi
Copy link

aagahi commented Jan 4, 2013

Headers could contains many values for same key (see Set-Cookie - http://en.wikipedia.org/wiki/Http_cookie)

As s suggestion here is a dummy impl:

def getResponseHeaders(conn: HttpURLConnection): Map[String, List[String]] = {
  // according to javadoc, there can be a headerField value where the HeaderFieldKey is null
  // at the 0th row in some implementations.  In that case it's the http status line
  val map = Stream.from(0).map(i => i -> conn.getHeaderField(i)).takeWhile(_._2 != null).map{ case (i, value) =>
    Option(conn.getHeaderFieldKey(i)).getOrElse("Status") -> value
  }.toList.groupBy(_._1)
  for ( (k,v) <- map ) yield  k -> v.map(_._2)
}
@hoffrocket
Copy link
Member

thanks, released 0.3.6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants