add tc_http auto test

This commit is contained in:
ruanshudong 2020-06-09 21:03:58 +08:00
parent b318cd79ea
commit e642785516
7 changed files with 5613 additions and 5006 deletions

View File

@ -0,0 +1,841 @@
//
// Created by jarod on 2020/2/20.
//
#include "util/tc_http.h"
#include "util/tc_common.h"
#include "util/tc_file.h"
#include "gtest/gtest.h"
using namespace tars;
class HttpTest : public testing::Test
{
public:
//添加日志
static void SetUpTestCase()
{
cout<<"SetUpTestCase"<<endl;
}
static void TearDownTestCase()
{
cout<<"TearDownTestCase"<<endl;
}
virtual void SetUp() //TEST跑之前会执行SetUp
{
cout<<"SetUp"<<endl;
}
virtual void TearDown() //TEST跑完之后会执行TearDown
{
cout<<"TearDown"<<endl;
}
};
TEST_F(HttpTest, testCheckRequestURL) //此时使用的是TEST_F宏
{
string s = string("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
TC_HttpRequest req;
ASSERT_TRUE(req.decode(s));
ASSERT_TRUE(req.getRequestUrl() == "/a/b");
ASSERT_TRUE(req.getURL().getDomain() == "www.qq.com");
}
TEST_F(HttpTest, testEncodeString) //此时使用的是TEST_F宏
{
string s = string("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
// s += string("a", 1024);
TC_HttpRequest req;
req.decode(s);
int64_t t = TC_Common::now2us();
int count = 100000;
int i = 0;
while(++i<count) {
string s;
s = req.encode();
}
ASSERT_TRUE(req.decode(s));
ASSERT_TRUE(req.getRequestUrl() == "/a/b");
ASSERT_TRUE(req.getURL().getDomain() == "www.qq.com");
cout << "testEncodeString::cost: " << TC_Common::now2us() - t << "us, " << 1.*(TC_Common::now2us() - t)/count << "us" << endl;
}
TEST_F(HttpTest, testEncodeVector) //此时使用的是TEST_F宏
{
string s = string("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
s += string("a", 1024);
TC_HttpRequest req;
req.decode(s);
int64_t t = TC_Common::now2us();
int count = 100000;
int i = 0;
while(++i<count) {
vector<char> buff;
req.encode(buff);
}
cout << "testEncodeVector::cost: " << TC_Common::now2us() - t << "us, " << 1.*(TC_Common::now2us() - t)/count << "us" << endl;
}
TEST_F(HttpTest, testEncodeBuffString) //此时使用的是TEST_F宏
{
string s = string("GET /a/b?name=value&ccc=ddd HTTP/1.1\\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
int64_t t = TC_Common::now2us();
TC_HttpRequest req;
req.decode(s);
TC_NetWorkBuffer buff(NULL);
int count = 100000;
int i = 0;
while(++i<count) {
req.encode(buff);
}
cout << "testEncodeBuffString::cost: " << TC_Common::now2us() - t << "us, " << 1.*(TC_Common::now2us() - t)/count << "us" << endl;
}
TEST_F(HttpTest, testDecodeString) //此时使用的是TEST_F宏
{
string s = string("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
int64_t t = TC_Common::now2us();
int count = 100000;
int i = 0;
while(++i<count) {
TC_HttpRequest req;
req.decode(s);
}
cout << "testDecodeString::cost: " << TC_Common::now2us() - t << "us, " << 1.*(TC_Common::now2us() - t)/count << "us" << endl;
}
TEST_F(HttpTest, testDecodeBuffString) //此时使用的是TEST_F宏
{
string s = string("HTTP/1.1 200 OK\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
int count = 100000;
int i = 0;
vector<TC_NetWorkBuffer> vbuff;
while(i<count) {
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s);
vbuff.push_back(buff);
++i;
}
int64_t t = TC_Common::now2us();
i = 0;
while(i<count) {
TC_HttpResponse req;
ASSERT_TRUE(req.incrementDecode(vbuff[i]));
++i;
}
cout << "testDecodeBuffString::cost: " << TC_Common::now2us() - t << "us, " << 1.*(TC_Common::now2us() - t)/count << "us" << endl;
}
TEST_F(HttpTest, testCheckRequestString) //此时使用的是TEST_F宏
{
string s = string("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
int64_t t = TC_Common::now2us();
TC_HttpRequest req;
int count = 100000;
int i = 0;
while(++i<count) {
ASSERT_TRUE(req.checkRequest(s.c_str(), s.size()));
}
ASSERT_TRUE(req.decode(s));
ASSERT_TRUE(req.getRequestUrl() == "/a/b");
cout << req.getURL().getDomain() << endl;
ASSERT_TRUE(req.getURL().getDomain() == "www.qq.com");
cout << "testCheckRequestString::cost: " << TC_Common::now2us() - t << "us, " << 1.*(TC_Common::now2us() - t)/count << "us" << endl;
}
TEST_F(HttpTest, testCheckRequestBuff) //此时使用的是TEST_F宏
{
string s = string("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n")
+string("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n")
+string("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n")
+string("Accept-Encoding: gzip\r\n")
+string("Accept-Language: zh-cn,zh;q=0.5\r\n")
+string("Connection: close\r\n")
+string("Host: www.qq.com\r\n")
+string("Q-GUID: 08f0373a192a45778cc8567d1c641475\r\n")
+string("Q-UA: SQB12_GA/120450&SMTT_3/020100&SYM3&201514&E71&V2\r\n")
+string("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
int64_t t = TC_Common::now2us();
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
TC_HttpRequest req;
int count = 100000;
int i = 0;
while(++i<count) {
ASSERT_TRUE(req.checkRequest(buff));
}
cout << "testCheckRequestBuff::cost: " << TC_Common::now2us() - t << "us, " << 1.*(TC_Common::now2us() - t)/count << "us" << endl;
}
TEST_F(HttpTest, testHttpFinish) //此时使用的是TEST_F宏
{
string body = "abdefghigk";
vector<string> sbuff;
sbuff.push_back("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n");
sbuff.push_back("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n");
sbuff.push_back("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n");
sbuff.push_back("Accept-Encoding: gzip\r\n");
sbuff.push_back("Content-Length: " + TC_Common::tostr(body.size()) + "\r\n");
sbuff.push_back("Connection: close\r\n");
sbuff.push_back("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
string header;
for(auto s : sbuff)
{
header += s;
}
string s = header + body;
TC_HttpRequest request;
ASSERT_TRUE(request.checkRequest(s.c_str(), s.size()));
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(buff.checkHttp() == TC_NetWorkBuffer::PACKET_FULL);
}
TEST_F(HttpTest, testHttpFinishNoLength) //此时使用的是TEST_F宏
{
vector<string> sbuff;
sbuff.push_back("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n");
sbuff.push_back("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n");
sbuff.push_back("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n");
sbuff.push_back("Accept-Encoding: gzip\r\n");
sbuff.push_back("Connection: close\r\n");
sbuff.push_back("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
string header;
for(auto s : sbuff)
{
header += s;
}
string s = header;
TC_HttpRequest request;
ASSERT_TRUE(request.checkRequest(s.c_str(), s.size()));
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(buff.checkHttp() == TC_NetWorkBuffer::PACKET_FULL);
}
TEST_F(HttpTest, testHttpNoFinish) //此时使用的是TEST_F宏
{
string body = "abdefghigk";
vector<string> sbuff;
sbuff.push_back("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n");
sbuff.push_back("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n");
sbuff.push_back("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n");
sbuff.push_back("Accept-Encoding: gzip\r\n");
sbuff.push_back("Content-Length: " + TC_Common::tostr(body.size() + 1) + "\r\n");
sbuff.push_back("Connection: close\r\n");
sbuff.push_back("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
string header;
for(auto s : sbuff)
{
header += s;
}
string s = header + body;
TC_HttpRequest request;
ASSERT_TRUE(!request.checkRequest(s.c_str(), s.size()));
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(buff.checkHttp() == TC_NetWorkBuffer::PACKET_LESS);
}
TEST_F(HttpTest, testHttpRequestChunked) //此时使用的是TEST_F宏
{
vector<string> body;
body.push_back("abasdfadefghiadfagk1");
body.push_back("abdasdfadfaefghigk2");
body.push_back("abdsaefghigk3");
body.push_back("abdeasdfafasfasfasfasdfasffghigk4");
vector<string> sbuff;
sbuff.push_back("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n");
sbuff.push_back("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n");
sbuff.push_back("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n");
sbuff.push_back("Accept-Encoding: gzip\r\n");
sbuff.push_back("Transfer-Encoding: chunked\r\n");
sbuff.push_back("Connection: close\r\n");
sbuff.push_back("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
stringstream data;
for(auto s : sbuff)
{
data << s;
}
string sbody;
for(auto s : body)
{
sbody += s;
data << hex << s.size() << "\r\n" << s << "\r\n";
}
data << 0 << "\r\n\r\n";
string s = data.str();
TC_HttpRequest request;
ASSERT_TRUE(request.checkRequest(s.c_str(), s.size()));
ASSERT_TRUE(request.decode(s));
ASSERT_TRUE(request.getContent() == sbody);
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
request.reset();
ASSERT_TRUE(request.checkRequest(buff));
}
TEST_F(HttpTest, testHttpRequestChunkedNoFinish) //此时使用的是TEST_F宏
{
vector<string> body;
body.push_back("abasdfadefghiadfagk1");
body.push_back("abdasdfadfaefghigk2");
body.push_back("abdsaefghigk3");
body.push_back("abdeasdfafasfasfasfasdfasffghigk4");
vector<string> sbuff;
sbuff.push_back("GET /a/b?name=value&ccc=ddd HTTP/1.1\r\n");
sbuff.push_back("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n");
sbuff.push_back("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n");
sbuff.push_back("Accept-Encoding: gzip\r\n");
sbuff.push_back("Transfer-Encoding: chunked\r\n");
sbuff.push_back("Connection: close\r\n");
sbuff.push_back("User-Agent: E71/SymbianOS/9.1 Series60/3.0\r\n\r\n");
stringstream data;
for(auto s : sbuff)
{
data << s;
}
data << hex << body[0].size() << "\r\n" << body[0] << "\r\n";
data << hex << body[1].size() << "\r\n" << body[1] << "\r\n";
data << hex << body[2].size() ;
string s = data.str();
TC_HttpRequest request;
ASSERT_TRUE(!request.checkRequest(s.c_str(), s.size()));
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(!request.checkRequest(buff));
}
TEST_F(HttpTest, testHttpResponse) //此时使用的是TEST_F宏
{
string body = "abcdef";
vector<string> sbuff;
sbuff.push_back("HTTP/1.1 200 OK\r\n");
sbuff.push_back("Content-Length: " + TC_Common::tostr(body.size()) + "\r\n");
sbuff.push_back("\r\n");
string header;
for(auto s : sbuff)
{
header += s;
}
string s = header + body;
{
TC_HttpResponse response;
ASSERT_TRUE(response.decode(s));
ASSERT_TRUE(response.getContent() == body);
}
{
TC_HttpResponse response;
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(response.incrementDecode(buff));
ASSERT_TRUE(response.getContent() == body);
}
}
TEST_F(HttpTest, testHttpResponseNoFinish) //此时使用的是TEST_F宏
{
string body = "abcdef";
vector<string> sbuff;
sbuff.push_back("HTTP/1.1 200 OK\r\n");
sbuff.push_back("Content-Length: " + TC_Common::tostr(body.size() + 1) + "\r\n");
sbuff.push_back("\r\n");
string header;
for(auto s : sbuff)
{
header += s;
}
string s = header + body;
{
TC_HttpResponse response;
ASSERT_TRUE(!response.decode(s));
}
{
TC_HttpResponse response;
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(!response.incrementDecode(buff));
}
}
TEST_F(HttpTest, testHttpResponseNoLength) //此时使用的是TEST_F宏
{
vector<string> sbuff;
sbuff.push_back("HTTP/1.1 200 OK\r\n");
sbuff.push_back("Connection: close\r\n");
sbuff.push_back("\r\n");
string header;
for(auto s : sbuff)
{
header += s;
}
string s = header;
{
TC_HttpResponse response;
ASSERT_TRUE(response.decode(s));
}
{
TC_HttpResponse response;
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(response.incrementDecode(buff));
}
}
TEST_F(HttpTest, testHttpResponseIncrementFinish) //此时使用的是TEST_F宏
{
string body = "abcdeasdfadfsff";
vector<string> sbuff;
sbuff.push_back("HTTP/1.1 200 OK\r\n");
sbuff.push_back("Content-Length: " + TC_Common::tostr(body.size()) + "\r\n");
sbuff.push_back("\r\n");
string header;
for(auto s : sbuff)
{
header += s;
}
string s = header;
{
TC_HttpResponse response;
ASSERT_TRUE(!response.decode(s));
}
{
TC_HttpResponse response;
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(!response.incrementDecode(buff));
}
s = header + body;
{
TC_HttpResponse response;
ASSERT_TRUE(response.decode(s));
}
{
TC_HttpResponse response;
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(response.incrementDecode(buff));
}
}
TEST_F(HttpTest, testHttpResponseChunked) //此时使用的是TEST_F宏
{
vector<string> body;
body.push_back("abdefghiasdfasdfsadfsadfsagk1");
body.push_back("abdefghasdfaaigk2");
body.push_back("abdefghigadsfadsfk3");
body.push_back("abdefgsfagasasdfasfdfdfsdfsfsdfdsffsdfsdfhigk4");
vector<string> sbuff;
sbuff.push_back("HTTP/1.1 200 OK\r\n");
sbuff.push_back("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n");
sbuff.push_back("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n");
sbuff.push_back("Transfer-Encoding: chunked\r\n");
sbuff.push_back("Connection: close\r\n\r\n");
stringstream data;
for(auto s : sbuff)
{
data << s;
}
string sbody;
for(auto s : body)
{
sbody += s;
data << hex << s.size() << "\r\n" << s << "\r\n";
}
data << 0 << "\r\n\r\n";
string s = data.str();
{
TC_HttpResponse response;
ASSERT_TRUE(response.decode(s));
ASSERT_TRUE(response.getContent() == sbody);
}
{
TC_HttpResponse response;
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(response.incrementDecode(buff));
ASSERT_TRUE(response.getContent() == sbody);
}
}
TEST_F(HttpTest, testHttpResponseChunkedNoFinish) //此时使用的是TEST_F宏
{
vector<string> body;
body.push_back("abdefasdfasfasghigk1");
body.push_back("asdfaabdeafghigk2");
body.push_back("abasdfasdfasdfasdfasdfasdfasfasdefghigk3");
body.push_back("abdefgfasdfasdfasdfasdfadfigk4");
vector<string> sbuff;
sbuff.push_back("HTTP/1.1 200 OK\r\n");
sbuff.push_back("Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n");
sbuff.push_back("Accept-Charset: utf-8,gb2321;q=0.7,*;q=0.7\r\n");
sbuff.push_back("Transfer-Encoding: chunked\r\n");
sbuff.push_back("Connection: close\r\n\r\n");
stringstream data;
for(auto s : sbuff)
{
data << s;
}
data << hex << body[0].size() << "\r\n" << body[0] << "\r\n";
data << hex << body[1].size() << "\r\n" << body[1] << "\r\n";
data << hex << body[2].size() << "\r\n" << "abc";
string s = data.str();
{
TC_HttpResponse response;
ASSERT_TRUE(!response.decode(s));
}
{
TC_HttpResponse response;
TC_NetWorkBuffer buff(NULL);
buff.addBuffer(s.c_str(), s.size());
ASSERT_TRUE(!response.incrementDecode(buff));
}
}
TEST_F(HttpTest, testWeb) //此时使用的是TEST_F宏
{
string url = "www.qq.com";
TC_HttpRequest stHttpReq;
// stHttpReq.setCacheControl("no-cache");
// stHttpReq.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36");
stHttpReq.setUserAgent("E71/SymbianOS/9.1 Series60/3.0");
stHttpReq.setHeader("Connection", "Close");
stHttpReq.setAcceptEncoding("gzip, deflate, br");
stHttpReq.setGetRequest(url);
string sSendBuffer = stHttpReq.encode();
TC_HttpResponse stHttpRsp;
int iRet = stHttpReq.doRequest(stHttpRsp, 5000);
if(iRet != 0)
{
cout << iRet << endl;
}
string file = stHttpReq.getURL().getDomain() + ".html";
auto headers = stHttpRsp.getHeaders();
cout << "request:" << url << endl;
cout << TC_Common::tostr(headers.begin(), headers.end(), "\r\n") << endl;
TC_File::save2file(file, stHttpRsp.getContent());
// ASSERT_TRUE(stHttpRsp.getContentLength() == TC_File::getFileSize(file));
}
void testCookie(const string &sRspURL, const string &sReqURL, const vector<string> &vsCookie)
{
cout << sRspURL << "=>" << sReqURL << "-----------------------------------" << endl;
TC_HttpCookie cookie;
cookie.addCookie(sRspURL, vsCookie);
list<TC_HttpCookie::Cookie> vCookie = cookie.getAllCookie();
cout << "All Cookie:" << sRspURL << "-----------------------------------" << endl;
list<TC_HttpCookie::Cookie>::iterator it = vCookie.begin();
while(it != vCookie.end())
{
cout << TC_Common::tostr(it->_data.begin(), it->_data.end(), "; ") << ", " << it->_expires << ", " << it->_path << endl;
++it;
}
cout << "-----------------------------------" << endl << endl;
string sCookie;
cookie.getCookieForURL(sReqURL, sCookie);
cout << TC_Common::tostr(sCookie) << endl;
cout << "-----------------------------------" << endl << endl;
}
TEST_F(HttpTest, testCookie) //此时使用的是TEST_F宏
{
ASSERT_TRUE(TC_HttpCookie::matchDomain("qq.com", "www.qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".qq.com", "www.qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".qq.com", "qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain("t.qq.com", "www.qq.com") == false);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".t.qq.com", "www.qq.com") == false);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".t.qq.com", "t.qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".com", "www.qq.com") == false);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".com", "qq.com") == false);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".y.qq.com", "x.y.qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".x.y.qq.com", "x.y.qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".qq.com", "x.y.qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain(".qq.com", "y.qq.com") == true);
ASSERT_TRUE(TC_HttpCookie::matchDomain("qq.com", "y.qq.com") == true);
cout << TC_Common::now2GMTstr() << endl;
string gmt = TC_Common::tm2GMTstr(time(NULL) + 10);
string s = "HTTP/1.1 200 OK\r\n";// 200 Aouut Error\r\n";
s += "Set-Cookie: n1=1; a=1; c=d; Path=/; Domain=qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n2=2; a=0; c=d; Path=/abc/def; Domain=.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n3=3; a=5; c=d; Path=/abc/def/aaa; Domain=.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n4=4; a=6; c=d; Path=/abc; Domain=.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n5=5; a=2; c=d; Path=/; Domain=.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n6=6; c=3; Path=/; Domain=y.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n7=7; c=3; Path=/abc; Domain=.y.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n8=6; c=3; Path=/; Domain=x.y.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n9=7; c=4; Path=/; Domain=.x.y.qq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n10=7; c=4; Path=/; Domain=qqq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n11=7; c=4; Path=/; Domain=.qqq.com; Expires=" + gmt + "\r\n";
s += "Set-Cookie: n12=8; c=4; Expires=" + gmt + "\r\n";
s += "Accept-Ranges: bytes\r\n\r\n";
TC_HttpResponse rsp;
rsp.decode(s);
cout << "-----------------------------------" << endl;
vector<string> vsCookie = rsp.getSetCookie();
cout << TC_Common::tostr(vsCookie.begin(), vsCookie.end(), "\r\n") << endl << endl;
testCookie("http://www.qq.com", "http://www.qq.com", vsCookie);
testCookie("http://www.qq.com/abc/def", "http://www.qq.com", vsCookie);
testCookie("http://www.qq.com/abc/def", "http://www.qq.com/abc", vsCookie);
cout << endl;
testCookie("http://www.qq.com", "http://qq.com", vsCookie);
testCookie("http://www.qq.com/abc/def/aaa", "http://www.qq.com/abc/def/aaa", vsCookie);
testCookie("http://www.qq.com/abc/def/aaa", "http://www.qq.com", vsCookie);
testCookie("http://www.qq.com", "http://www.qq.com/abc/def", vsCookie);
testCookie("http://qq.com", "http://qq.com/abc/def", vsCookie);
testCookie("http://qq.com", "http://t.qq.com/abc/def", vsCookie);
testCookie("http://qq.com", "http://y.qq.com/", vsCookie);
testCookie("http://qq.com", "http://y.qq.com/abc", vsCookie);
testCookie("http://x.y.qq.com", "http://x.y.qq.com", vsCookie);
}
//
//void Test_TC_Http::main()
//{
// testCheckRequestURL();
//
// testEncodeString();
// testEncodeVector();
// testEncodeBuffString();
//
// testDecodeString();
//
// testDecodeBuffString();
//
// testCheckRequestString();
// testCheckRequestBuff();
//
// testHttpFinishNoLength();
//
// testHttpFinish();
//
// testHttpNoFinish();
//
// testHttpRequestChunked();
//
// testHttpResponse();
//
// testHttpResponseNoFinish();
//
// testHttpResponseNoLength();
//
// testHttpResponseIncrementFinish();
//
// testHttpResponseChunked();
//
// testHttpRequestChunkedNoFinish();
//
// testHttpResponseChunkedNoFinish();
//
//// testWeb("http://www.baidu.com");
//// testWeb("http://www.httpwatch.com/httpgallery/chunked/chunkedimage.aspx");
//// testWeb("http://www.qq.com");
//
//// testCookie();
//}

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
#define FLEX_SCANNER #define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 37 #define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0 #if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA #define FLEX_BETA
#endif #endif
@ -47,6 +47,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t; typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t; typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t; typedef uint32_t flex_uint32_t;
typedef uint64_t flex_uint64_t;
#else #else
typedef signed char flex_int8_t; typedef signed char flex_int8_t;
typedef short int flex_int16_t; typedef short int flex_int16_t;
@ -54,6 +55,7 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */ /* Limits of integral types. */
#ifndef INT8_MIN #ifndef INT8_MIN
@ -84,8 +86,6 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)
#endif #endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */ #endif /* ! FLEXINT_H */
#ifdef __cplusplus #ifdef __cplusplus
@ -176,7 +176,7 @@ extern FILE *yyin, *yyout;
*/ */
#define YY_LESS_LINENO(n) \ #define YY_LESS_LINENO(n) \
do { \ do { \
int yyl;\ yy_size_t yyl;\
for ( yyl = n; yyl < yyleng; ++yyl )\ for ( yyl = n; yyl < yyleng; ++yyl )\
if ( yytext[yyl] == '\n' )\ if ( yytext[yyl] == '\n' )\
--yylineno;\ --yylineno;\
@ -369,7 +369,7 @@ static void yy_fatal_error (yyconst char msg[] );
*/ */
#define YY_DO_BEFORE_ACTION \ #define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \ (yytext_ptr) = yy_bp; \
yyleng = (size_t) (yy_cp - yy_bp); \ yyleng = (yy_size_t) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \ (yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \ *yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp; (yy_c_buf_p) = yy_cp;
@ -513,7 +513,7 @@ int yy_flex_debug = 0;
#define YY_MORE_ADJ 0 #define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET #define YY_RESTORE_YY_MORE_OFFSET
char *yytext; char *yytext;
#line 1 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 1 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
/** /**
* Tencent is pleased to support the open source community by making Tars available. * Tencent is pleased to support the open source community by making Tars available.
* *
@ -529,7 +529,7 @@ char *yytext;
* CONDITIONS OF ANY KIND, either express or implied. See the License for the * CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License. * specific language governing permissions and limitations under the License.
*/ */
#line 20 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 20 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
#include <map> #include <map>
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -649,7 +649,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's, /* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite(). * we now use fwrite().
*/ */
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #define ECHO fwrite( yytext, yyleng, 1, yyout )
#endif #endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -660,7 +660,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \ { \
int c = '*'; \ int c = '*'; \
size_t n; \ yy_size_t n; \
for ( n = 0; n < max_size && \ for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \ buf[n] = (char) c; \
@ -742,7 +742,7 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 67 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 67 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
#line 749 "tars.lex.cpp" #line 749 "tars.lex.cpp"
@ -840,12 +840,12 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 69 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 69 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ BEGIN(INCL); } { BEGIN(INCL); }
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 71 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 71 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH )
{ {
@ -878,7 +878,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(INCL): case YY_STATE_EOF(INCL):
#line 101 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 101 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
--include_file_stack_ptr; --include_file_stack_ptr;
if ( include_file_stack_ptr < 0 ) if ( include_file_stack_ptr < 0 )
@ -897,14 +897,14 @@ case YY_STATE_EOF(INCL):
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 117 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 117 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
return TARS_SCOPE_DELIMITER; return TARS_SCOPE_DELIMITER;
} }
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 121 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 121 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
// C++ comment // C++ comment
bool e = false; bool e = false;
@ -925,7 +925,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 139 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 139 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
// C comment // C comment
bool e = false; bool e = false;
@ -976,7 +976,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 187 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 187 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
StringGrammarPtr ident = new StringGrammar; StringGrammarPtr ident = new StringGrammar;
ident->v = yytext; ident->v = yytext;
@ -987,7 +987,7 @@ YY_RULE_SETUP
case 7: case 7:
/* rule 7 can match eol */ /* rule 7 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 194 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 194 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
StringGrammarPtr ident = new StringGrammar; StringGrammarPtr ident = new StringGrammar;
ident->v = yytext; ident->v = yytext;
@ -1000,7 +1000,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 204 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 204 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
StringGrammarPtr str = new StringGrammar; StringGrammarPtr str = new StringGrammar;
bool e = false; bool e = false;
@ -1115,7 +1115,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 316 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 316 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
errno = 0; errno = 0;
IntergerGrammarPtr ptr = new IntergerGrammar; IntergerGrammarPtr ptr = new IntergerGrammar;
@ -1140,7 +1140,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 338 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 338 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
errno = 0; errno = 0;
FloatGrammarPtr ptr = new FloatGrammar; FloatGrammarPtr ptr = new FloatGrammar;
@ -1175,7 +1175,7 @@ YY_RULE_SETUP
case 11: case 11:
/* rule 11 can match eol */ /* rule 11 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 369 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 369 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
if(yytext[0] == '\n') if(yytext[0] == '\n')
{ {
@ -1185,7 +1185,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 376 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 376 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
if(yytext[0] < 32 || yytext[0] > 126) if(yytext[0] < 32 || yytext[0] > 126)
{ {
@ -1204,7 +1204,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 392 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 392 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1211 "tars.lex.cpp" #line 1211 "tars.lex.cpp"
@ -1398,7 +1398,7 @@ static int yy_get_next_buffer (void)
{ /* Not enough room in the buffer - grow it. */ { /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */ /* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset = int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf); (int) ((yy_c_buf_p) - b->yy_ch_buf);
@ -1531,7 +1531,7 @@ static int yy_get_next_buffer (void)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 51); yy_is_jam = (yy_current_state == 51);
return yy_is_jam ? 0 : yy_current_state; return yy_is_jam ? 0 : yy_current_state;
} }
static void yyunput (int c, register char * yy_bp ) static void yyunput (int c, register char * yy_bp )
@ -1623,7 +1623,7 @@ static int yy_get_next_buffer (void)
case EOB_ACT_END_OF_FILE: case EOB_ACT_END_OF_FILE:
{ {
if ( yywrap( ) ) if ( yywrap( ) )
return EOF; return 0;
if ( ! (yy_did_buffer_switch_on_eof) ) if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE; YY_NEW_FILE;
@ -1764,6 +1764,10 @@ static void yy_load_buffer_state (void)
yyfree((void *) b ); yyfree((void *) b );
} }
#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer. /* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer, * This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF. * such as during a yyrestart() or at EOF.
@ -1968,8 +1972,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes. * scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan * @param bytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param len the number of bytes in the buffer pointed to by @a bytes.
* *
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
*/ */
@ -1977,8 +1981,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
char *buf; char *buf;
yy_size_t n; yy_size_t n, i;
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */ /* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2; n = _yybytes_len + 2;
@ -2211,7 +2214,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 392 "/home/jarod/TarsFramework/tarscpp/tools/tarsgrammar/tars.l" #line 392 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,14 @@
/* A Bison parser, made by GNU Bison 3.0.4. */ /* A Bison parser, made by GNU Bison 2.3. */
/* Bison interface for Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation; either version 2, or (at your option)
(at your option) any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -15,7 +16,9 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
@ -30,65 +33,87 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_YY_TARS_TAB_HPP_INCLUDED /* Tokens. */
# define YY_YY_TARS_TAB_HPP_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
enum yytokentype /* Put the tokens into the symbol table, so that GDB and other debuggers
{ know about them. */
TARS_VOID = 258, enum yytokentype {
TARS_STRUCT = 259, TARS_VOID = 258,
TARS_BOOL = 260, TARS_STRUCT = 259,
TARS_BYTE = 261, TARS_BOOL = 260,
TARS_SHORT = 262, TARS_BYTE = 261,
TARS_INT = 263, TARS_SHORT = 262,
TARS_DOUBLE = 264, TARS_INT = 263,
TARS_FLOAT = 265, TARS_DOUBLE = 264,
TARS_LONG = 266, TARS_FLOAT = 265,
TARS_STRING = 267, TARS_LONG = 266,
TARS_VECTOR = 268, TARS_STRING = 267,
TARS_MAP = 269, TARS_VECTOR = 268,
TARS_NAMESPACE = 270, TARS_MAP = 269,
TARS_INTERFACE = 271, TARS_NAMESPACE = 270,
TARS_IDENTIFIER = 272, TARS_INTERFACE = 271,
TARS_OUT = 273, TARS_IDENTIFIER = 272,
TARS_OP = 274, TARS_OUT = 273,
TARS_KEY = 275, TARS_OP = 274,
TARS_ROUTE_KEY = 276, TARS_KEY = 275,
TARS_REQUIRE = 277, TARS_ROUTE_KEY = 276,
TARS_OPTIONAL = 278, TARS_REQUIRE = 277,
TARS_CONST_INTEGER = 279, TARS_OPTIONAL = 278,
TARS_CONST_FLOAT = 280, TARS_CONST_INTEGER = 279,
TARS_FALSE = 281, TARS_CONST_FLOAT = 280,
TARS_TRUE = 282, TARS_FALSE = 281,
TARS_STRING_LITERAL = 283, TARS_TRUE = 282,
TARS_SCOPE_DELIMITER = 284, TARS_STRING_LITERAL = 283,
TARS_CONST = 285, TARS_SCOPE_DELIMITER = 284,
TARS_ENUM = 286, TARS_CONST = 285,
TARS_UNSIGNED = 287, TARS_ENUM = 286,
BAD_CHAR = 288 TARS_UNSIGNED = 287,
}; BAD_CHAR = 288
};
#endif #endif
/* Tokens. */
#define TARS_VOID 258
#define TARS_STRUCT 259
#define TARS_BOOL 260
#define TARS_BYTE 261
#define TARS_SHORT 262
#define TARS_INT 263
#define TARS_DOUBLE 264
#define TARS_FLOAT 265
#define TARS_LONG 266
#define TARS_STRING 267
#define TARS_VECTOR 268
#define TARS_MAP 269
#define TARS_NAMESPACE 270
#define TARS_INTERFACE 271
#define TARS_IDENTIFIER 272
#define TARS_OUT 273
#define TARS_OP 274
#define TARS_KEY 275
#define TARS_ROUTE_KEY 276
#define TARS_REQUIRE 277
#define TARS_OPTIONAL 278
#define TARS_CONST_INTEGER 279
#define TARS_CONST_FLOAT 280
#define TARS_FALSE 281
#define TARS_TRUE 282
#define TARS_STRING_LITERAL 283
#define TARS_SCOPE_DELIMITER 284
#define TARS_CONST 285
#define TARS_ENUM 286
#define TARS_UNSIGNED 287
#define BAD_CHAR 288
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE; typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_TARS_TAB_HPP_INCLUDED */

File diff suppressed because it is too large Load Diff

View File

@ -35,9 +35,9 @@ bool TC_SpinLock::tryLock() const
int trys = 100; int trys = 100;
for (; trys > 0 && _flag.test_and_set(std::memory_order_acquire); --trys) for (; trys > 0 && _flag.test_and_set(std::memory_order_acquire); --trys)
{ {
#if TARGET_PLATFORM_LINUX //#if TARGET_PLATFORM_LINUX
asm volatile("rep; nop" ::: "memory"); // asm volatile("rep; nop" ::: "memory");
#endif //#endif
} }