/** * This is used to remove the named header from the response. This removes all header values * assigned to the specified name. If it does not exist then this will return without modifying * the HTTP response. Headers names removed are case insensitive. * * @param name the HTTP message header to remove from the response */ public void remove(String name) { String token = name.toLowerCase(); String value = names.get(token); if (value != null) { names.remove(token); } values.remove(token); }
/** * This is used to acquire all the individual header values from the message. The header values * provided by this are unparsed and represent the actual string values that have been added to * the message keyed by a given header name. * * @param name the name of the header to get the values for * @param token this provides a lower case version of the header * @return this returns a list of the values for the header name */ private List<String> getAll(String name, String token) { Series series = new Series(); String value = names.get(token); if (value == null) { names.put(token, name); } values.put(token, series); return series.getValues(); }
/** * The <code>setCookie</code> method is used to set a cookie value with the cookie name. This will * add a cookie to the response stored under the name of the cookie, when this is committed it * will be added as a Set-Cookie header to the resulting response. * * @param cookie this is the cookie to be added to the response * @return returns the cookie that has been set in the response */ public Cookie setCookie(Cookie cookie) { String name = cookie.getName(); if (name != null) { cookies.put(name, cookie); } return cookie; }
/** * This is used to acquire all the individual header values from the message. The header values * provided by this are unparsed and represent the actual string values that have been added to * the message keyed by a given header name. * * @param name the name of the header to get the values for * @return this returns a list of the values for the header name */ public List<String> getAll(String name) { String token = name.toLowerCase(); Series series = values.get(token); if (series == null) { return getAll(name, token); } return series.getValues(); }
/** * This is used to acquire the names of the of the headers that have been set in the response. * This can be used to acquire all header values by name that have been set within the response. * If no headers have been set this will return an empty list. * * @return a list of strings representing the set header names */ public List<String> getNames() { return names.getValues(); }
/** * This returns all <code>Cookie</code> objects stored under the specified name. This is used to * retrieve cookies that have been set with the <code>setCookie</code> methods. If there are no * cookies then this will return an empty list. * * @return returns all the <code>Cookie</code> in the response */ public List<Cookie> getCookies() { return cookies.getValues(); }
/** * This returns the <code>Cookie</code> object stored under the specified name. This is used to * retrieve cookies that have been set with the <code>setCookie</code> methods. If the cookie does * not exist under the specified name this will return null. * * @param name this is the name of the cookie to be retrieved * @return returns the <code>Cookie</code> by the given name */ public Cookie getCookie(String name) { return cookies.get(name); }