Support multi-valued HTTP headers

Issue #252 resolved
Former user created an issue

HttpMessage needs to support multiple Set-Cookie headers as per the http specification.

Currently only one cookie is returned. (The last one found as headers are in a simple map).

https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies

Comments (7)

  1. Olaf Rode

    Hi this issue is not resolved yet. Currently only one value will be stored when processing the response received by HttpRequest.send() --> values.get(0). Currently this leads to problems as I'm loosing a 'Set-Cookie' value. :-(

            // Set headers
            for (Map.Entry<String,List<String>> responseHeader: conn.getHeaderFields().entrySet()) {
    
                if (responseHeader.getKey() == null) {
                    continue; // skip header
                }
    
                List<String> values = responseHeader.getValue();
                if (values == null || values.isEmpty() || values.get(0) == null) {
                    continue; // skip header
                }
    
                response.setHeader(responseHeader.getKey(), values.get(0));
            }
    

    All the best

    Olaf

  2. Log in to comment