summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOleg Morozenkov <omorozenkov@gmail.com>2015-11-12 18:12:28 +0300
committerOleg Morozenkov <omorozenkov@gmail.com>2015-11-12 18:12:28 +0300
commit91574f7b7f28e5c7c03c2af5507d7dff4fa31fed (patch)
tree1e6062b822b03d18b47d3a400ec89e1a9dbb663d /src
parent7179cc9bd0d43bf0cf645bcb3247c1183dd8c818 (diff)
parent2f857ce94ae9fe80bb0d0bd96aa40e262a24f30a (diff)
Merge pull request #6 from flode/master
Fix several bugs
Diffstat (limited to 'src')
-rw-r--r--src/Api.cpp2
-rw-r--r--src/net/HttpParser.cpp12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/Api.cpp b/src/Api.cpp
index 7e05621..9c8259f 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -246,7 +246,7 @@ vector<Update::Ptr> Api::getUpdates(int32_t offset, int32_t limit, int32_t timeo
if (timeout) {
args.push_back(HttpReqArg("timeout", timeout));
}
- return TgTypeParser::getInstance().parseJsonAndGetArray<Update>(&TgTypeParser::parseJsonAndGetUpdate, sendRequest("getUpdates", args), "result");
+ return TgTypeParser::getInstance().parseJsonAndGetArray<Update>(&TgTypeParser::parseJsonAndGetUpdate, sendRequest("getUpdates", args));
}
void Api::setWebhook(const string& url) const {
diff --git a/src/net/HttpParser.cpp b/src/net/HttpParser.cpp
index 7c4f9e2..4b57bc1 100644
--- a/src/net/HttpParser.cpp
+++ b/src/net/HttpParser.cpp
@@ -196,11 +196,15 @@ string HttpParser::parseHttp(bool isRequest, const string& data, map<string, str
string HttpParser::parseHttp(bool isRequest, const string& data) {
size_t headerEnd = data.find("\r\n\r\n");
- if (headerEnd == data.npos) {
+ if (headerEnd != data.npos) {
+ headerEnd += 4;
+ } else {
headerEnd = data.find("\n\n");
- }
- if (headerEnd == data.npos) {
- headerEnd = 0;
+ if (headerEnd != data.npos) {
+ headerEnd += 2;
+ } else {
+ headerEnd = 0;
+ }
}
return data.substr(headerEnd);
}