removing stringstream
This commit is contained in:
@@ -21,8 +21,11 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#ifndef BASIC_DATASTRUCTURES_H
|
||||
#define BASIC_DATASTRUCTURES_H
|
||||
#include <string>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../Util/StringUtil.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
const std::string okString = "HTTP/1.0 200 OK\r\n";
|
||||
@@ -70,15 +73,13 @@ struct Reply {
|
||||
std::vector<boost::asio::const_buffer> HeaderstoBuffers();
|
||||
std::string content;
|
||||
static Reply stockReply(status_type status);
|
||||
void setSize(unsigned size) {
|
||||
for (std::size_t i = 0; i < headers.size(); ++i) {
|
||||
Header& h = headers[i];
|
||||
if("Content-Length" == h.name) {
|
||||
std::stringstream sizeString;
|
||||
sizeString << size;
|
||||
h.value = sizeString.str();
|
||||
}
|
||||
}
|
||||
void setSize(const unsigned size) {
|
||||
BOOST_FOREACH (const Header& h, headers) {
|
||||
if("Content-Length" == h.name) {
|
||||
std::string sizeString;
|
||||
intToString(size,h.value );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+10
-8
@@ -33,6 +33,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#include "../DataStructures/HashTable.h"
|
||||
#include "../Plugins/BasePlugin.h"
|
||||
#include "../Plugins/RouteParameters.h"
|
||||
#include "../Util/StringUtil.h"
|
||||
#include "../typedefs.h"
|
||||
|
||||
namespace http {
|
||||
@@ -71,16 +72,17 @@ public:
|
||||
bool result = boost::spirit::qi::parse(it, request.end(), apiParser); // returns true if successful
|
||||
if (!result || (it != request.end()) ) {
|
||||
rep = http::Reply::stockReply(http::Reply::badRequest);
|
||||
std::stringstream content;
|
||||
int position = std::distance(request.begin(), it);
|
||||
content << "Input seems to be malformed close to position " << position << "<br>";
|
||||
content << "<pre>";
|
||||
content << req.uri << "<br>";
|
||||
std::string tmp_position_string;
|
||||
intToString(position, tmp_position_string);
|
||||
rep.content += "Input seems to be malformed close to position ";
|
||||
rep.content += "<br><pre>";
|
||||
rep.content += request;
|
||||
rep.content += tmp_position_string;
|
||||
rep.content += "<br>";
|
||||
for(unsigned i = 0, end = std::distance(request.begin(), it); i < end; ++i)
|
||||
content << " ";
|
||||
content << "^" << "<br>";
|
||||
content << "</pre>";
|
||||
rep.content += content.str();
|
||||
rep.content += " ";
|
||||
rep.content += "^<br></pre>";
|
||||
} else {
|
||||
//Finished parsing, lets call the right plugin to handle the request
|
||||
if(pluginMap.Holds(routeParameters.service)) {
|
||||
|
||||
Reference in New Issue
Block a user