[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog cygnal/http.cpp cygnal/http.h c...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash ChangeLog cygnal/http.cpp cygnal/http.h c... |
Date: |
Thu, 13 Dec 2007 00:54:30 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 07/12/13 00:54:30
Modified files:
. : ChangeLog
cygnal : http.cpp http.h
cygnal/testsuite/cygnal.all: test_http.cpp
Log message:
* cygnal/http.{cpp,h}: Extract the fields with multiple values
into arrays, instead of just extracting the whole string.
* cygnal/testsuite/cygnal.all/test_http.cpp: Test for multiple
values in HTTP header fields.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5154&r2=1.5155
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/testsuite/cygnal.all/test_http.cpp?cvsroot=gnash&r1=1.3&r2=1.4
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5154
retrieving revision 1.5155
diff -u -b -r1.5154 -r1.5155
--- ChangeLog 13 Dec 2007 00:26:49 -0000 1.5154
+++ ChangeLog 13 Dec 2007 00:54:29 -0000 1.5155
@@ -1,3 +1,10 @@
+2007-12-12 Rob Savoye <address@hidden>
+
+ * cygnal/http.{cpp,h}: Extract the fields with multiple values
+ into arrays, instead of just extracting the whole string.
+ * cygnal/testsuite/cygnal.all/test_http.cpp: Test for multiple
+ values in HTTP header fields.
+
2007-12-12 Sandro Santilli <address@hidden>
* server/parser/button_character_def.cpp (readDefineButton2):
Index: cygnal/http.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- cygnal/http.cpp 11 Dec 2007 03:23:02 -0000 1.10
+++ cygnal/http.cpp 13 Dec 2007 00:54:29 -0000 1.11
@@ -46,6 +46,7 @@
static const int readsize = 1024;
HTTP::HTTP()
+ : _keepalive(false)
{
// GNASH_REPORT_FUNCTION;
// struct status_codes *status = new struct status_codes;
@@ -87,6 +88,7 @@
log_error (_("Couldn't read initial GET Request"));
}
+ extractAccept(buffer);
extractMethod(buffer);
extractReferer(buffer);
extractHost(buffer);
@@ -199,8 +201,8 @@
_header << "Content-Type: text/html; charset=UTF-8" << endl;
break;
case SWF:
-// _header << "Content-Type: application/x-shockwave-flash" << endl;
- _header << "Content-Type: application/futuresplash" << endl;
+ _header << "Content-Type: application/x-shockwave-flash" << endl;
+// _header << "Content-Type: application/futuresplash" << endl;
break;
case VIDEO:
_header << "Content-Type: video/flv" << endl;
@@ -341,6 +343,43 @@
// Referer: http://localhost/software/gnash/tests/
// Connection: Keep-Alive, TE
// TE: deflate, gzip, chunked, identity, trailers
+int
+HTTP::extractAccept(const char *data) {
+// GNASH_REPORT_FUNCTION;
+
+ string body = data;
+ string::size_type start, end, length, pos;
+ string pattern = "Accept: ";
+
+ start = body.find(pattern, 0);
+ if (start == string::npos) {
+ return -1;
+ }
+ end = body.find("\r\n", start);
+ if (end == string::npos) {
+ end = body.find("\n", start);
+// return "error";
+ }
+
+ length = end-start-pattern.size();
+ start = start+pattern.size();
+ pos = start;
+ while (pos <= end) {
+ pos = (body.find(",", start) + 2);
+ if ((pos == string::npos) || (pos > end)) {
+ length = end - start;
+ } else {
+ length = pos - start - 2;
+ }
+ string substr = body.substr(start, length);
+// printf("FIXME: \"%s\"\n", substr.c_str());
+ _accept.push_back(substr);
+ start = pos;
+ }
+
+ return _accept.size();
+}
+
string
HTTP::extractMethod(const char *data) {
// GNASH_REPORT_FUNCTION;
@@ -389,25 +428,45 @@
return _referer;
}
-string
+int
HTTP::extractConnection(const char *data) {
// GNASH_REPORT_FUNCTION;
string body = data;
- string::size_type start, end;
+ string::size_type start, end, length, pos;
string pattern = "Connection: ";
start = body.find(pattern, 0);
if (start == string::npos) {
- return "error";
+ return -1;
}
end = body.find("\r\n", start);
if (end == string::npos) {
- return "error";
+ end = body.find("\n", start);
+// return "error";
+ }
+
+ length = end-start-pattern.size();
+ start = start+pattern.size();
+ string _connection = body.substr(start, length);
+ pos = start;
+ while (pos <= end) {
+ pos = (body.find(",", start) + 2);
+ if ((pos == string::npos) || (pos > end)) {
+ length = end - start;
+ } else {
+ length = pos - start - 2;
+ }
+ string substr = body.substr(start, length);
+// printf("FIXME: \"%s\"\n", substr.c_str());
+ _connections.push_back(substr);
+ if (substr == "Keep-Alive") {
+ _keepalive = true;
+ }
+ start = pos;
}
- _connection = body.substr(start+pattern.size(), end-start-1);
- return _connection;
+ return _connections.size();
}
string
@@ -452,113 +511,161 @@
return _agent;
}
-string
+int
HTTP::extractLanguage(const char *data) {
// GNASH_REPORT_FUNCTION;
string body = data;
- string::size_type start, end;
- string pattern = "Accept-Language: ";
+ string::size_type start, end, length, pos;
+ // match both Accept-Language and Content-Language
+ string pattern = "-Language: ";
start = body.find(pattern, 0);
if (start == string::npos) {
- return "error";
+ return -1;
}
end = body.find("\r\n", start);
if (end == string::npos) {
- return "error";
+ end = body.find("\n", start);
+// return "error";
+ }
+ length = end-start-pattern.size();
+ start = start+pattern.size();
+ pos = start;
+ while (pos <= end) {
+ pos = (body.find(",", start));
+ if ((pos == string::npos) || (pos >= end)) {
+ length = end - start;
+ } else {
+ length = pos - start;
+ }
+ string substr = body.substr(start, length);
+// printf("FIXME: \"%s\"\n", substr.c_str());
+ _language.push_back(substr);
+ start = pos + 2;
}
- _language = body.substr(start+pattern.size(), end-start-1);
- return _language;
+// _language = body.substr(start+pattern.size(), end-start-1);
+ return _language.size();
}
-string
+int
HTTP::extractCharset(const char *data) {
// GNASH_REPORT_FUNCTION;
string body = data;
- string::size_type start, end;
- string pattern = "Accept-Charset: ";
+ string::size_type start, end, length, pos;
+// match both Accept-Charset and Content-Charset
+ string pattern = "-Charset: ";
start = body.find(pattern, 0);
if (start == string::npos) {
- return "error";
+ return -1;
}
end = body.find("\r\n", start);
if (end == string::npos) {
- return "error";
+ end = body.find("\n", start);
+// return "error";
}
- _charset = body.substr(start+pattern.size(), end-start-1);
- return _charset;
+ length = end-start-pattern.size();
+ start = start+pattern.size();
+ string _connection = body.substr(start, length);
+ pos = start;
+ while (pos <= end) {
+ pos = (body.find(",", start) + 2);
+ if ((pos == string::npos) || (pos > end)) {
+ length = end - start;
+ } else {
+ length = pos - start - 2;
+ }
+ string substr = body.substr(start, length);
+// printf("FIXME: \"%s\"\n", substr.c_str());
+ _charset.push_back(substr);
+ start = pos;
+ }
+// _charset = body.substr(start+pattern.size(), end-start-1);
+ return _charset.size();
}
-string
+int
HTTP::extractEncoding(const char *data) {
// GNASH_REPORT_FUNCTION;
string body = data;
- string::size_type start, end;
- string pattern = "Accept-Encoding: ";
+ string::size_type start, end, length, pos;
+ // match both Accept-Encoding and Content-Encoding
+ string pattern = "-Encoding: ";
start = body.find(pattern, 0);
if (start == string::npos) {
- return "error";
+ return -1;
}
end = body.find("\r\n", start);
if (end == string::npos) {
- return "error";
+ end = body.find("\n", start);
+// return "error";
}
- _encoding = body.substr(start+pattern.size(), end-start-1);
- return _encoding;
+ length = end-start-pattern.size();
+ start = start+pattern.size();
+ string _connection = body.substr(start, length);
+ pos = start;
+ while (pos <= end) {
+ pos = (body.find(",", start) + 2);
+ if ((pos == string::npos) || (pos > end)) {
+ length = end - start;
+ } else {
+ length = pos - start - 2;
+ }
+ string substr = body.substr(start, length);
+// printf("FIXME: \"%s\"\n", substr.c_str());
+ _encoding.push_back(substr);
+ start = pos;
+ }
+
+// _encoding = body.substr(start+pattern.size(), end-start-1);
+ return _encoding.size();
}
-string
+int
HTTP::extractTE(const char *data) {
// GNASH_REPORT_FUNCTION;
string body = data;
- string::size_type start, end;
+ string::size_type start, end, length, pos;
string pattern = "TE: ";
start = body.find(pattern, 0);
if (start == string::npos) {
- return "error";
+ return -1;
}
end = body.find("\r\n", start);
if (end == string::npos) {
- return "error";
+ end = body.find("\n", start);
+// return "error";
}
- _te = body.substr(start+pattern.size(), end-start-1);
- return _te;
-}
-
-bool
-HTTP::keepAlive(const char *data)
-{
-// GNASH_REPORT_FUNCTION;
-
- if (strcasecmp(data, "Keep-Alive")) {
- return true;
+ length = end-start-pattern.size();
+ start = start+pattern.size();
+ pos = start;
+ while (pos <= end) {
+ pos = (body.find(",", start));
+ if ((pos == string::npos) || (pos >= end)) {
+ length = end - start;
} else {
- return false;
+ length = pos - start;
}
+ string substr = body.substr(start, length);
+// printf("FIXME: \"%s\"\n", substr.c_str());
+ _te.push_back(substr);
+ start = pos + 2;
+ }
+ return _te.size();
}
-bool
-HTTP::keepAlive()
-{
-// GNASH_REPORT_FUNCTION;
- // FIXME: is their a way to make find case insensitive that's
- // less than 20 lines long ?
- return keepAlive(_connection.c_str());
-}
-
- // Get the file type, so we know how to set the
- // Content-type in the header.
+// Get the file type, so we know how to set the
+// Content-type in the header.
HTTP::filetype_e
HTTP::getFileType(std::string filespec)
{
@@ -614,20 +721,35 @@
GNASH_REPORT_FUNCTION;
boost::mutex::scoped_lock lock(stl_mutex);
+ vector<string>::iterator it;
log_msg (_("==== The HTTP header breaks down as follows: ===="));
log_msg (_("Filespec: %s"), _filespec.c_str());
log_msg (_("URL: %s"), _url.c_str());
log_msg (_("Version: %s"), _version.c_str());
+ for (it = _accept.begin(); it != _accept.end(); it++) {
+ log_msg("Accept: \"%s\"", (*(it)).c_str());
+ }
log_msg (_("Method: %s"), _method.c_str());
log_msg (_("Referer: %s"), _referer.c_str());
- log_msg (_("Connection: %s"), _connection.c_str());
+ log_msg (_("Connections:"));
+ for (it = _connections.begin(); it != _connections.end(); it++) {
+ log_msg("Connection param is: \"%s\"", (*(it)).c_str());
+ }
log_msg (_("Host: %s"), _host.c_str());
log_msg (_("User Agent: %s"), _agent.c_str());
- log_msg (_("Language: %s"), _language.c_str());
- log_msg (_("Charset: %s"), _charset.c_str());
- log_msg (_("Encoding: %s"), _encoding.c_str());
- log_msg (_("TE: %s"), _te.c_str());
+ for (it = _language.begin(); it != _language.end(); it++) {
+ log_msg("Language: \"%s\"", (*(it)).c_str());
+ }
+ for (it = _charset.begin(); it != _charset.end(); it++) {
+ log_msg("Charset: \"%s\"", (*(it)).c_str());
+ }
+ for (it = _encoding.begin(); it != _encoding.end(); it++) {
+ log_msg("Encodings: \"%s\"", (*(it)).c_str());
+ }
+ for (it = _te.begin(); it != _te.end(); it++) {
+ log_msg("TE: \"%s\"", (*(it)).c_str());
+ }
log_msg (_("==== ==== ===="));
}
Index: cygnal/http.h
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- cygnal/http.h 11 Dec 2007 03:23:02 -0000 1.8
+++ cygnal/http.h 13 Dec 2007 00:54:29 -0000 1.9
@@ -26,6 +26,7 @@
#include "network.h"
#include <string>
#include <map>
+#include <vector>
namespace cygnal
{
@@ -119,15 +120,19 @@
HTTP &operator = (HTTP &obj);
// These methods extract the fields in the HTTP header.
+ // These all return the number of items found, or 0
+ int extractAccept(const char *data);
+ int extractLanguage(const char *data);
+ int extractCharset(const char *data);
+ int extractEncoding(const char *data);
+ int extractTE(const char *data);
+ int extractConnection(const char *data);
+
+ // These return the string that was found for this field.
std::string extractMethod(const char *data);
std::string extractReferer(const char *data);
- std::string extractConnection(const char *data);
std::string extractHost(const char *data);
std::string extractAgent(const char *data);
- std::string extractLanguage(const char *data);
- std::string extractCharset(const char *data);
- std::string extractEncoding(const char *data);
- std::string extractTE(const char *data);
// These methods add data to the fields in the HTTP header.
bool clearHeader() { _header.str(""); };
@@ -148,9 +153,6 @@
bool formatEncoding(const char *data);
bool formatTE(const char *data);
- bool keepAlive(const char *data);
- bool keepAlive();
-
// All HTTP messages are terminated with a blank line
void terminateHeader() { _header << std::endl; };
@@ -161,7 +163,29 @@
// Content-type in the header.
filetype_e getFileType(std::string filespec);
void dump();
+
+ // These accessors are used mostly just for debugging.
+ bool keepAlive() { return _keepalive; }
+ std::string getFilespec() { return _filespec; }
+ std::string getURL() { return _url; }
+ std::map<int, struct status_codes *> getStatusCodes()
+ { return _status_codes; }
+ std::string getVersion() { return _version; }
+ std::string getMethod() { return _method; }
+ std::string getReferer() { return _referer; }
+ std::vector<std::string> getLanguage() { return _language; }
+ std::vector<std::string> getConnection() { return _connections; }
+ std::vector<std::string> getTE() { return _te; }
+ std::vector<std::string> getCharset() { return _charset; }
+ std::vector<std::string> getEncoding() { return _encoding; }
+
+ int getHostPort(){ return _port; }
+ std::string getHost() { return _host; }
+ std::string getUserAgent() { return _agent; }
+
+
private:
+ std::stringstream _header;
filetype_e _filetype;
std::string _filespec;
std::string _url;
@@ -169,15 +193,18 @@
std::string _version;
std::string _method;
std::string _referer;
- std::string _connection;
std::string _host;
int _port;
std::string _agent;
- std::string _language;
- std::string _charset;
- std::string _encoding;
- std::string _te;
- std::stringstream _header;
+ std::vector<std::string> _connections;
+ std::vector<std::string> _language;
+ std::vector<std::string> _charset;
+ std::vector<std::string> _encoding;
+ std::vector<std::string> _te;
+ std::vector<std::string> _accept;
+ // Connection parameters we care about
+ bool _keepalive;
+// bool _te;
};
} // end of cygnal namespace
Index: cygnal/testsuite/cygnal.all/test_http.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/testsuite/cygnal.all/test_http.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- cygnal/testsuite/cygnal.all/test_http.cpp 12 Dec 2007 23:56:30 -0000
1.3
+++ cygnal/testsuite/cygnal.all/test_http.cpp 13 Dec 2007 00:54:29 -0000
1.4
@@ -25,7 +25,7 @@
#include <unistd.h>
#ifdef HAVE_GETOPT_H
- #include <getopt.h>
+# include <getopt.h>
#endif
#ifndef __GNUC__
@@ -84,12 +84,13 @@
// Check the Date field
// The date should look something like this:
// Date: Mon, 10 Dec 2007 GMT
- regcomp (®ex_pat, "[A-Z][a-z]*, [0-9]* [A-Z][a-z]* [0-9]* *GMT$",
+ regcomp (®ex_pat, "Date: [A-Z][a-z]*, [0-9]* [A-Z][a-z]* [0-9]* [0-9:]*
*GMT$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatDate()");
+ runtest.fail ("HTTP::formatDate()");
+ cerr << http.getHeader().c_str() << endl;
} else {
- runtest.pass ("Date::formatDate()");
+ runtest.pass ("HTTP::formatDate()");
}
regfree(®ex_pat);
@@ -100,9 +101,9 @@
regcomp (®ex_pat, "Content-Length: [0-9]*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatContentLength()");
+ runtest.fail ("HTTP::formatContentLength()");
} else {
- runtest.pass ("Date::formatContentLength()");
+ runtest.pass ("HTTP::formatContentLength()");
}
regfree(®ex_pat);
@@ -116,9 +117,9 @@
regcomp (®ex_pat, "Connection: [A-za-z-]*",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatConnection()");
+ runtest.fail ("HTTP::formatConnection()");
} else {
- runtest.pass ("Date::formatConnection()");
+ runtest.pass ("HTTP::formatConnection()");
}
regfree(®ex_pat);
@@ -131,9 +132,9 @@
regcomp (®ex_pat, "Host: [A-za-z-]*:[0-9]*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatHost()");
+ runtest.fail ("HTTP::formatHost()");
} else {
- runtest.pass ("Date::formatHost()");
+ runtest.pass ("HTTP::formatHost()");
}
regfree(®ex_pat);
@@ -146,9 +147,9 @@
regcomp (®ex_pat, "Accept-Language: en-US,en;q=0.9$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatLanguage()");
+ runtest.fail ("HTTP::formatLanguage()");
} else {
- runtest.pass ("Date::formatLanguage()");
+ runtest.pass ("HTTP::formatLanguage()");
}
regfree(®ex_pat);
@@ -161,9 +162,9 @@
regcomp (®ex_pat, "Accept-Charset: iso-8859-1.*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatCharset()");
+ runtest.fail ("HTTP::formatCharset()");
} else {
- runtest.pass ("Date::formatCharset()");
+ runtest.pass ("HTTP::formatCharset()");
}
regfree(®ex_pat);
@@ -175,9 +176,9 @@
regcomp (®ex_pat, "Accept-Encoding: deflate, gzip.*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatEncoding()");
+ runtest.fail ("HTTP::formatEncoding()");
} else {
- runtest.pass ("Date::formatEncoding()");
+ runtest.pass ("HTTP::formatEncoding()");
}
regfree(®ex_pat);
@@ -190,9 +191,9 @@
regcomp (®ex_pat, "TE: deflate, gzip,.*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatTE()");
+ runtest.fail ("HTTP::formatTE()");
} else {
- runtest.pass ("Date::formatTE()");
+ runtest.pass ("HTTP::formatTE()");
}
regfree(®ex_pat);
@@ -204,9 +205,9 @@
regcomp (®ex_pat, "User-Agent: Gnash 0.8.1-cvs.*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatAgent()");
+ runtest.fail ("HTTP::formatAgent()");
} else {
- runtest.pass ("Date::formatAgent()");
+ runtest.pass ("HTTP::formatAgent()");
}
regfree(®ex_pat);
@@ -216,12 +217,12 @@
http.clearHeader();
http.formatContentType(HTTP::SWF);
// cerr << "FIXME: " << http.getHeader() << endl;
- regcomp (®ex_pat, "Content-Type: application/futuresplash.*$",
+ regcomp (®ex_pat, "Content-Type: application/x-shockwave-flash.*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatContentType(type)");
+ runtest.fail ("HTTP::formatContentType(type)");
} else {
- runtest.pass ("Date::formatConetnType(type)");
+ runtest.pass ("HTTP::formatConetnType(type)");
}
regfree(®ex_pat);
@@ -231,9 +232,9 @@
regcomp (®ex_pat, "Content-Type: text/html.*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatContentType()");
+ runtest.fail ("HTTP::formatContentType()");
} else {
- runtest.pass ("Date::formatContenType()");
+ runtest.pass ("HTTP::formatContenType()");
}
regfree(®ex_pat);
@@ -245,9 +246,9 @@
regcomp (®ex_pat, "Referer: http://localhost.*index.html.*$",
REG_NOSUB|REG_NEWLINE);
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatReferer()");
+ runtest.fail ("HTTP::formatReferer()");
} else {
- runtest.pass ("Date::formatReferer()");
+ runtest.pass ("HTTP::formatReferer()");
}
regfree(®ex_pat);
@@ -258,9 +259,9 @@
regcomp (®ex_pat, "HTTP/1.1 200
OK.*Date:.*Connection:.*-Length.*-Type:.*$",
REG_NOSUB); // note that we do want to look for NL
if (regexec (®ex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0))
{
- runtest.fail ("Date::formatHeader(port)");
+ runtest.fail ("HTTP::formatHeader(port)");
} else {
- runtest.pass ("Date::formatheader(port)");
+ runtest.pass ("HTTP::formatheader(port)");
}
regfree(®ex_pat);
@@ -291,83 +292,98 @@
string result;
result = http.extractReferer(buffer);
if (result == "http://localhost/software/gnash/tests/index.html") {
- runtest.fail ("Date::extractReferer()");
+ runtest.fail ("HTTP::extractReferer()");
} else {
- runtest.pass ("Date::extractReferer()");
+ runtest.pass ("HTTP::extractReferer()");
}
result = http.extractHost(buffer);
if (result == "localhost:4080") {
- runtest.fail ("Date::extractHost()");
+ runtest.fail ("HTTP::extractHost()");
} else {
- runtest.pass ("Date::extractHost()");
+ runtest.pass ("HTTP::extractHost()");
}
result = http.extractAgent(buffer);
if (result == "Gnash/0.8.1-cvs (X11; Linux i686; U; en)") {
- runtest.fail ("Date::extractAgent()");
+ runtest.fail ("HTTP::extractAgent()");
} else {
- runtest.pass ("Date::extractAgent()");
+ runtest.pass ("HTTP::extractAgent()");
}
- result = http.extractLanguage(buffer);
- if (result == "en-US,en;q=0.9") {
- runtest.fail ("Date::extractLanguage(Accept-)");
+ int count;
+ count = http.extractLanguage(buffer);
+ std::vector<std::string> language = http.getLanguage();
+ if ((count == 2) &&
+ (language[0] == "en-US") &&
+ (language[1] == "en")) {
+ runtest.fail ("HTTP::extractLanguage(Accept-)");
} else {
- runtest.pass ("Date::extractLanguage(Accept-)");
+ runtest.pass ("HTTP::extractLanguage(Accept-)");
}
- result = http.extractLanguage(buffer2);
- if (result == "en-US,en;q=0.9") {
- runtest.fail ("Date::extractLanguage(Content-)");
+ count = http.extractLanguage(buffer2);
+ language = http.getLanguage();
+ if ((count == 2) &&
+ (language[0] == "en-US") &&
+ (language[1] == "en")) {
+ runtest.fail ("HTTP::extractLanguage(Content-)");
} else {
- runtest.pass ("Date::extractLanguage(Content-)");
+ runtest.pass ("HTTP::extractLanguage(Content-)");
}
result = http.extractCharset(buffer);
- if (result == "iso-8859-1, utf-8, utf-16, *;q=0.1") {
- runtest.fail ("Date::extractCharset(Accept-)");
+ std::vector<std::string> charsets = http.getCharset();
+ if ((count == 3) &&
+ (charsets[0] == "iso-8859-1") &&
+ (charsets[1] == "utf-8") &&
+ (charsets[2] == "utf-16")) {
+ runtest.fail ("HTTP::extractCharset(Accept-)");
+ } else {
+ runtest.pass ("HTTP::extractCharset(Accept-)");
+ }
+ count = http.extractCharset(buffer2);
+ charsets = http.getCharset();
+ if ((count == 3) &&
+ (charsets[0] == "iso-8859-1") &&
+ (charsets[1] == "utf-8") &&
+ (charsets[2] == "utf-16")) {
+ runtest.fail ("HTTP::extractCharset(Content-)");
} else {
- runtest.pass ("Date::extractCharset(Accept-)");
- }
- result = http.extractCharset(buffer2);
- if (result == "iso-8859-1, utf-8, utf-16, *;q=0.1") {
- runtest.fail ("Date::extractCharset(Content-)");
- } else {
- runtest.pass ("Date::extractCharset(Content-)");
+ runtest.pass ("HTTP::extractCharset(Content-)");
}
- result = http.extractConnection(buffer);
+ count = http.extractConnection(buffer);
std::vector<std::string> connections = http.getConnection();
- if ((result == "Keep-Alive, TE") &&
+ if ((count == 2) &&
(connections[0] == "Keep-Alive") &&
(connections[1] == "TE")) {
- runtest.pass ("Date::extractConnection()");
+ runtest.pass ("HTTP::extractConnection()");
} else {
- runtest.fail ("Date::extractConnection()");
+ runtest.fail ("HTTP::extractConnection()");
}
- result = http.extractEncoding(buffer);
- if (result == "deflate, gzip, x-gzip, identity, *;q=0") {
- runtest.fail ("Date::extractEncoding(Accept-)");
+ count = http.extractEncoding(buffer);
+ std::vector<std::string> encoding = http.getEncoding();
+ if ((count == 4) &&
+ (encoding[0] == "deflate") &&
+ (encoding[1] == "gzip") &&
+ (encoding[2] == "chunked") &&
+ (encoding[3] == "identity")) {
+ runtest.fail ("HTTP::extractEncoding(Accept-)");
} else{
- runtest.pass ("Date::extractEncoding(Accept-)");
- }
- result = http.extractEncoding(buffer2);
- if (result == "deflate, gzip, x-gzip, identity, *;q=0") {
- runtest.fail ("Date::extractEncoding(Content-)");
- } else {
- runtest.pass ("Date::extractEncoding(Content-)");
+ runtest.pass ("HTTP::extractEncoding(Accept-)");
}
- result = http.extractTE(buffer);
+ count = http.extractTE(buffer);
std::vector<std::string> te = http.getTE();
- if ((te[0] == "deflate") &&
+ if ((count == 5) &&
+ (te[0] == "deflate") &&
(te[1] == "gzip") &&
(te[2] == "chunked") &&
(te[3] == "identity") &&
(te[4] == "trailers")) {
- runtest.pass ("Date::extractTE()");
+ runtest.pass ("HTTP::extractTE()");
} else {
- runtest.fail ("Date::extractTE()");
+ runtest.fail ("HTTP::extractTE()");
}
// http.formatHeader(666, RTMP);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog cygnal/http.cpp cygnal/http.h c...,
Rob Savoye <=