-/* $Id$
-
-This file is part of libmsphttp
-Copyright © 2008 Mikkosoft Productions, Mikko Rasa
-Distributed under the LGPL
-*/
-
#include <cstdlib>
+#include <msp/core/maputils.h>
#include <msp/strings/formatter.h>
#include <msp/strings/utils.h>
#include "message.h"
const string &Message::get_header(const string &hdr) const
{
- HeaderMap::const_iterator i = headers.find(normalize_header_name(hdr));
- if(i==headers.end())
- throw KeyError("Undefined header", hdr);
-
- return i->second;
+ return get_item(headers, normalize_header_name(hdr));
}
void Message::add_content(const string &d)
{
unsigned lf = d.find('\n', start);
if(lf==string::npos)
- throw InvalidParameterValue("Incomplete response");
+ throw invalid_argument("Message::parse_headers");
if(lf==start || (d[start]=='\r' && lf==start+1))
return lf+1;
unsigned colon = d.find(':', start);
if(colon>lf)
- throw InvalidParameterValue("No colon in header");
+ throw invalid_argument("Message::parse_headers");
set_header(d.substr(start, colon-start), strip(d.substr(colon+1, lf-colon-1)));