]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/response.cpp
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / http / response.cpp
index ede249b7e11afa467e5423f4c4a54faa091fc59c..6005d35ae6e1e26bf62837262485302e5d3df117 100644 (file)
@@ -1,6 +1,6 @@
-#include <msp/strings/formatter.h>
-#include <msp/strings/utils.h>
 #include "response.h"
+#include <msp/strings/format.h>
+#include <msp/strings/utils.h>
 
 using namespace std;
 
@@ -23,8 +23,10 @@ Response Response::parse(const string &str)
 {
        Response result;
 
-       unsigned lf = str.find('\n');
-       vector<string> parts = split(str.substr(0, lf), ' ', 2);
+       string::size_type lf = str.find('\n');
+       if(lf==0)
+               throw invalid_argument("Response::parse");
+       vector<string> parts = split(str.substr(0, lf-(str[lf-1]=='\r')), ' ', 2);
        if(parts.size()<2)
                throw invalid_argument("Response::parse");