2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "utils/HttpParser.h"
22 #include "utils/StdString.h"
24 #include "gtest/gtest.h"
26 TEST(TestHttpParser, General)
29 CStdString str = "POST /path/script.cgi HTTP/1.0\r\n"
30 "From: amejia@xbmc.org\r\n"
31 "User-Agent: XBMC/snapshot (compatible; MSIE 5.5; Windows NT"
33 "Content-Type: application/x-www-form-urlencoded\r\n"
34 "Content-Length: 35\r\n"
36 "home=amejia&favorite+flavor=orange\r\n";
37 CStdString refstr, varstr;
39 EXPECT_EQ(a.Done, a.addBytes(str.c_str(), str.length()));
42 varstr = a.getMethod();
43 EXPECT_STREQ(refstr.c_str(), varstr.c_str());
45 refstr = "/path/script.cgi";
47 EXPECT_STREQ(refstr.c_str(), varstr.c_str());
50 varstr = a.getQueryString();
51 EXPECT_STREQ(refstr.c_str(), varstr.c_str());
53 refstr = "home=amejia&favorite+flavor=orange\r\n";
55 EXPECT_STREQ(refstr.c_str(), varstr.c_str());
57 refstr = "application/x-www-form-urlencoded";
58 varstr = a.getValue("content-type");
59 EXPECT_STREQ(refstr.c_str(), varstr.c_str());
61 EXPECT_EQ((unsigned)35, a.getContentLength());