gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog cygnal/cygnal.cpp cygnal/http.c...


From: Rob Savoye
Subject: [Gnash-commit] gnash ChangeLog cygnal/cygnal.cpp cygnal/http.c...
Date: Thu, 13 Dec 2007 19:46:34 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    07/12/13 19:46:34

Modified files:
        .              : ChangeLog 
        cygnal         : cygnal.cpp http.cpp http.h 
        cygnal/testsuite/cygnal.all: test_crc.cpp test_http.cpp 

Log message:
                * cygnal/cygnal.cpp: Check the file type to set the HTTP
                Content-Tytpe field correctly. Also handle "file not found".
                * cygnal/http.cpp: Trap file not found errors. Format responses
                correctly, including a 404 error. Make all fields with multiple
                values an array.
                * cygnal/http.h: Add an ERROR for file type. Stash the message
                body and filesize as private data.
                * cygnal/testsuite/cygnal.all/test_crc.cpp: Use the global 
LogFile
                instance so verbosity works.
                * cygnal/testsuite/cygnal.all/test_http.cpp: Use the global
                LogFile instance so verbosity works. Test responses.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5164&r2=1.5165
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/cygnal.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/testsuite/cygnal.all/test_crc.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/testsuite/cygnal.all/test_http.cpp?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5164
retrieving revision 1.5165
diff -u -b -r1.5164 -r1.5165
--- ChangeLog   13 Dec 2007 19:03:54 -0000      1.5164
+++ ChangeLog   13 Dec 2007 19:46:32 -0000      1.5165
@@ -1,3 +1,17 @@
+2007-12-13  Rob Savoye  <address@hidden>
+
+       * cygnal/cygnal.cpp: Check the file type to set the HTTP
+       Content-Tytpe field correctly. Also handle "file not found".
+       * cygnal/http.cpp: Trap file not found errors. Format responses
+       correctly, including a 404 error. Make all fields with multiple
+       values an array.
+       * cygnal/http.h: Add an ERROR for file type. Stash the message
+       body and filesize as private data.
+       * cygnal/testsuite/cygnal.all/test_crc.cpp: Use the global LogFile
+       instance so verbosity works.
+       * cygnal/testsuite/cygnal.all/test_http.cpp: Use the global
+       LogFile instance so verbosity works. Test responses.
+
 2007-12-13 Sandro Santilli <address@hidden>
 
        * server/PropertyList.cpp (addGetterSetter): since the function

Index: cygnal/cygnal.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/cygnal.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- cygnal/cygnal.cpp   12 Dec 2007 23:56:29 -0000      1.16
+++ cygnal/cygnal.cpp   13 Dec 2007 19:46:33 -0000      1.17
@@ -104,7 +104,7 @@
 const char *docroot;
 
 // This is the number of times a thread loop continues, for debugging only
-int thread_retries;
+int thread_retries = 10;
 
 // This is added to the default ports for testing so it doesn't
 // conflict with apache on the same machine.
@@ -187,15 +187,15 @@
     struct thread_params rtmp_data;
     struct thread_params http_data;
     struct thread_params ssl_data;
-    rtmp_data.port = port_offset + RTMP;
+    rtmp_data.port = port_offset + 1935;
 //    boost::thread rtmp_port(boost::bind(&rtmp_thread, &rtmp_data));
 
-    http_data.port = port_offset + RTMPT;
+    http_data.port = port_offset + 80;
     Statistics st;
     http_data.statistics = &st;
     boost::thread http_port(boost::bind(&http_thread, &http_data));
 
-    ssl_data.port = port_offset + RTMPTS;
+    ssl_data.port = port_offset + 443;
 //    boost::thread ssl_port(boost::bind(&ssl_thread, &ssl_data));
     
 //    boost::thread rtmp_port(&rtmp_thread);
@@ -241,14 +241,12 @@
        filespec = url.substr(0, pos);
        parameters = url.substr(pos + 1, url.size());
        // Get the file size for the HTTP header
-       if (stat(filespec.c_str(), &filestats) == 0) {
-           filesize = filestats.st_size;
-       } else {
-           filesize = 0;
+       
+       if (www.getFileType(filespec) == HTTP::ERROR) {
+           www.formatErrorResponse(HTTP::NOT_FOUND);
        }
        
-       www.getFileType(filespec);
-       www.sendGetReply(filesize);
+       www.sendGetReply(HTTP::LIFE_IS_GOOD);
 //     strcpy(thread_data.filespec, filespec.c_str());
 //     thread_data.statistics = conndata->statistics;
        

Index: cygnal/http.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cygnal/http.cpp     13 Dec 2007 00:54:29 -0000      1.11
+++ cygnal/http.cpp     13 Dec 2007 19:46:33 -0000      1.12
@@ -46,7 +46,7 @@
 static const int readsize = 1024;
 
 HTTP::HTTP() 
-    : _keepalive(false)
+    : _port(80), _filesize(0), _keepalive(false)
 {
 //    GNASH_REPORT_FUNCTION;
 //    struct status_codes *status = new struct status_codes;
@@ -59,6 +59,20 @@
 //    GNASH_REPORT_FUNCTION;
 }
 
+bool
+HTTP::clearHeader()
+{
+    _header.str("");
+    _body.str("");
+    _charset.clear();
+    _connections.clear();
+    _language.clear();
+    _encoding.clear();
+    _te.clear();
+    _accept.clear();
+    _filesize = 0;
+};
+
 HTTP &
 HTTP::operator = (HTTP& /*obj*/)
 {
@@ -107,6 +121,7 @@
         log_error (_("Got bogus GET request"));
     }
 
+    _filespec = _url;
     return _url;
 }
 
@@ -136,6 +151,33 @@
 }
 
 bool
+HTTP::formatErrorResponse(http_status_e code)
+{
+    GNASH_REPORT_FUNCTION;
+
+    // First build the message body, so we know how to set Content-Length
+    _body << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" << endl;
+    _body << "<html><head>" << endl;
+    _body << "<title>" << code << " Not Found</title>" << endl;
+    _body << "</head><body>" << endl;
+    _body << "<h1>Not Found</h1>" << endl;
+    _body << "<p>The requested URL " << _filespec << " was not found on this 
server.</p>" << endl;
+    _body << "<hr>" << endl;
+    _body << "<address>Cygnal (GNU/Linux) Server at localhost Port " << _port 
<< " </address>" << endl;
+    _body << "</body></html>" << endl;
+    _body << endl;
+
+    // First build the header
+    _header << "HTTP/1.1 " << code << " Not Found" << endl;
+    formatDate();
+    formatServer();
+    _filesize = _body.str().size();
+    formatContentLength(_filesize);
+    formatConnection("close");
+    formatContentType(HTTP::HTML);
+}
+
+bool
 HTTP::formatDate()
 {
     GNASH_REPORT_FUNCTION;
@@ -165,6 +207,20 @@
 }
 
 bool
+HTTP::formatServer()
+{
+    GNASH_REPORT_FUNCTION;
+    _header << "Server: Cygnal (GNU/Linux)" << endl;
+}
+
+bool
+HTTP::formatServer(const char *data)
+{
+    GNASH_REPORT_FUNCTION;
+    _header << "Server: " << data << endl;
+}
+
+bool
 HTTP::formatMethod(const char *data)
 {
     GNASH_REPORT_FUNCTION;
@@ -194,7 +250,7 @@
 bool
 HTTP::formatContentType(filetype_e filetype)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     
     switch (filetype) {
       case HTML:
@@ -216,30 +272,37 @@
 }
 
 bool
+HTTP::formatContentLength()
+{
+//    GNASH_REPORT_FUNCTION;
+    _header << "Content-Length: " << _filesize << endl;
+}
+
+bool
 HTTP::formatContentLength(int filesize)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     _header << "Content-Length: " << filesize << endl;
 }
 
 bool
 HTTP::formatHost(const char *host)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     _header << "Host: " << host << endl;
 }
 
 bool
 HTTP::formatAgent(const char *agent)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     _header << "User-Agent: " << agent << endl;
 }
 
 bool
 HTTP::formatLanguage(const char *lang)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
 
     // For some browsers this appears to also be Content-Language
     _header << "Accept-Language: " << lang << endl;
@@ -268,35 +331,20 @@
 }
 
 bool
-HTTP::sendGetReply(int filesize)
+HTTP::sendGetReply(http_status_e code)
 {
     GNASH_REPORT_FUNCTION;
     
-//     const char reply[] =
-//         "HTTP/1.1 200 OK\r\n"
-//         "Date: Sun, 20 Apr 2006 04:20:00 GMT\r\n"
-//         "Content-Type: application/futuresplash\r\n"
-//         "Connection: close\r\n"
-//         "Content-Length: XX      \r\n"
-//         "\r\n"                  // All HTTP messages are followed by a 
blank line.
-//         ;
-
-// //     // This is a bit ugly, but we splice the file size onto the request 
string
-// //     // without any memory allocation, which could incur a small 
performance hit.
-//      char *length = strstr(reply, " XX");
-//      sprintf(length, " %d", filesize);
-//      case SWF:
-//       _header << "Content-Type: application/futuresplash" << endl;
-//       break;
- // // FIXME:  Doesn't this write to a const array?  And doesn't it fail to
-// // // supply the two \r\n's needed to finish the string?  --gnu
-
-    formatHeader(filesize, RTMP);
+    formatHeader(_filesize, RTMP);
     int ret = writeNet(_header.str().c_str(), _header.str().size());
+    if ( _body.str().size() > 0) {
+       ret += writeNet(_body.str().c_str(), _body.str().size());
+    }
 
-    if (ret >= 0 && (unsigned)ret == _header.str().size()) {
+    if (ret >= 0) {
         log_msg (_("Sent GET Reply"));
 //        log_msg (_("Sent GET Reply: %s"), _header.str().c_str());
+       clearHeader();
     } else {
         log_msg (_("Couldn't send GET Reply, writeNet returned %d"), ret);
        return false;
@@ -366,6 +414,9 @@
     pos = start;
     while (pos <= end) {
        pos = (body.find(",", start) + 2);
+       if (pos <= start) {
+           return _encoding.size();
+       }
        if ((pos == string::npos) || (pos > end)) {
            length = end - start;
        } else {
@@ -452,6 +503,9 @@
     pos = start;
     while (pos <= end) {
        pos = (body.find(",", start) + 2);
+       if (pos <= start) {
+           return _encoding.size();
+       }
        if ((pos == string::npos) || (pos > end)) {
            length = end - start;
        } else {
@@ -516,7 +570,7 @@
 //    GNASH_REPORT_FUNCTION;
     
     string body = data;
-    string::size_type start, end, length, pos;
+    string::size_type start, end, length, pos, terminate;
     // match both Accept-Language and Content-Language
     string pattern = "-Language: ";
     
@@ -532,17 +586,25 @@
     length = end-start-pattern.size();
     start = start+pattern.size();
     pos = start;
+    terminate = (body.find(";", start));
+    if (terminate == string::npos) {
+       terminate = end;
+    }
+    
     while (pos <= end) {
        pos = (body.find(",", start));
-       if ((pos == string::npos) || (pos >= end)) {
-           length = end - start;
+       if (pos <= start) {
+           return _encoding.size();
+       }
+       if ((pos == string::npos) || (pos >= terminate)) {
+           length = terminate - 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;
+       start = pos + 1;
     }
     
 //    _language = body.substr(start+pattern.size(), end-start-1);
@@ -554,7 +616,7 @@
 //    GNASH_REPORT_FUNCTION;
     
     string body = data;
-    string::size_type start, end, length, pos;
+    string::size_type start, end, length, pos, terminate;
 // match both Accept-Charset and Content-Charset
     string pattern = "-Charset: ";
     
@@ -572,10 +634,17 @@
     start = start+pattern.size();
     string _connection = body.substr(start, length);
     pos = start;
+    terminate = (body.find(";", start));
+    if (terminate == string::npos) {
+       terminate = end;
+    }
     while (pos <= end) {
        pos = (body.find(",", start) + 2);
-       if ((pos == string::npos) || (pos > end)) {
-           length = end - start;
+       if (pos <= start) {
+           return _encoding.size();
+       }
+       if ((pos == string::npos) || (pos >= terminate)) {
+           length = terminate - start;
        } else {
            length = pos - start - 2;
        }
@@ -593,7 +662,7 @@
 //    GNASH_REPORT_FUNCTION;
     
     string body = data;
-    string::size_type start, end, length, pos;
+    string::size_type start, end, length, pos, terminate;
     // match both Accept-Encoding and Content-Encoding
     string pattern = "-Encoding: ";
     
@@ -611,10 +680,18 @@
     start = start+pattern.size();
     string _connection = body.substr(start, length);
     pos = start;
+    // Drop anything after a ';' character
+    terminate = (body.find(";", start));
+    if (terminate == string::npos) {
+       terminate = end;
+    }
     while (pos <= end) {
        pos = (body.find(",", start) + 2);
-       if ((pos == string::npos) || (pos > end)) {
-           length = end - start;
+       if (pos <= start) {
+           return _encoding.size();
+       }
+       if ((pos == string::npos) || (pos >= terminate)) {
+           length = terminate - start;
        } else {
            length = pos - start - 2;
        }
@@ -651,6 +728,9 @@
     pos = start;
     while (pos <= end) {
        pos = (body.find(",", start));
+       if (pos <= start) {
+           return _encoding.size();
+       }
        if ((pos == string::npos) || (pos >= end)) {
            length = end - start;
        } else {
@@ -667,7 +747,7 @@
 // Get the file type, so we know how to set the
 // Content-type in the header.
 HTTP::filetype_e
-HTTP::getFileType(std::string filespec)
+HTTP::getFileType(std::string &filespec)
 {
     GNASH_REPORT_FUNCTION;    
     bool try_again = true;
@@ -676,6 +756,7 @@
 
     while (try_again) {
        try_again = false;
+//     cerr << "Trying to open " << actual_filespec << endl;
        if (stat(actual_filespec.c_str(), &st) == 0) {
            // If it's a directory, then we emulate what apache
            // does, which is to load the index.html file in that
@@ -712,8 +793,14 @@
                    }
                }
            }
+       } else {
+           _filetype = HTTP::ERROR;
        } // end of stat()
     } // end of try_waiting
+
+    _filesize = st.st_mode;
+
+    return _filetype;
 }
 
 void
@@ -728,7 +815,7 @@
     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("Accept param: \"%s\"", (*(it)).c_str());
     }
     log_msg (_("Method: %s"), _method.c_str());
     log_msg (_("Referer: %s"), _referer.c_str());
@@ -739,16 +826,16 @@
     log_msg (_("Host: %s"), _host.c_str());
     log_msg (_("User Agent: %s"), _agent.c_str());
     for (it = _language.begin(); it != _language.end(); it++) {
-        log_msg("Language: \"%s\"", (*(it)).c_str());
+        log_msg("Language param: \"%s\"", (*(it)).c_str());
     }
     for (it = _charset.begin(); it != _charset.end(); it++) {
-        log_msg("Charset: \"%s\"", (*(it)).c_str());
+        log_msg("Charset param: \"%s\"", (*(it)).c_str());
     }
     for (it = _encoding.begin(); it != _encoding.end(); it++) {
-        log_msg("Encodings: \"%s\"", (*(it)).c_str());
+        log_msg("Encodings param: \"%s\"", (*(it)).c_str());
     }
     for (it = _te.begin(); it != _te.end(); it++) {
-        log_msg("TE: \"%s\"", (*(it)).c_str());
+        log_msg("TE param: \"%s\"", (*(it)).c_str());
     }
     log_msg (_("==== ==== ===="));
 }

Index: cygnal/http.h
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- cygnal/http.h       13 Dec 2007 00:54:29 -0000      1.9
+++ cygnal/http.h       13 Dec 2007 19:46:33 -0000      1.10
@@ -34,6 +34,7 @@
 class HTTP : public gnash::Network
 {
 public:
+// as defined by the W3: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
     typedef enum {
         // 1xx: Informational - Request received, continuing process
         CONTINUE = 100,
@@ -82,7 +83,8 @@
         BAD_GATEWAY = 502,
         SERVICE_UNAVAILABLE = 503,
         GATEWAY_TIMEOUT = 504,
-        HTTP_VERSION_NOT_SUPPORTED = 505
+        HTTP_VERSION_NOT_SUPPORTED = 505,
+       LIFE_IS_GOOD = 1234
     } http_status_e;
     typedef enum {
         OPTIONS,
@@ -99,7 +101,8 @@
         const char *msg;
     };
     typedef enum {
-       NONE,
+       ERROR = -1,
+       NONE = 0,
        HTML,
        SWF,
        VIDEO,
@@ -113,7 +116,7 @@
     std::string waitForGetRequest(Network &net);
     
     // Handle the GET request response
-    bool sendGetReply(int filesize);
+    bool sendGetReply(http_status_e code);
 //    bool sendGetReply(Network &net);
 
     // Make copies of ourself
@@ -135,14 +138,17 @@
     std::string extractAgent(const char *data);
 
     // These methods add data to the fields in the HTTP header.
-    bool clearHeader() { _header.str(""); };
+    bool clearHeader();
     bool formatHeader(int filesize, const short type);
     bool formatHeader(const short type);
     bool formatRequest(const char *url, http_method_e req);
     bool formatMethod(const char *data);
     bool formatDate();
+    bool formatServer();
+    bool formatServer(const char *data);
     bool formatReferer(const char *data);
     bool formatConnection(const char *data);
+    bool formatContentLength();
     bool formatContentLength(int filesize);
     bool formatContentType();
     bool formatContentType(filetype_e type);
@@ -153,19 +159,26 @@
     bool formatEncoding(const char *data);
     bool formatTE(const char *data);
 
+    bool formatErrorResponse(http_status_e err);
+    
     // All HTTP messages are terminated with a blank line
     void terminateHeader() { _header << std::endl; };
     
     // Return the header that's been built up.
     std::string getHeader() { return _header.str(); };
 
+    // Return the body that's been built up.
+    std::string getBody() { return _body.str(); };
+
     // Get the file type, so we know how to set the
     // Content-type in the header.
-    filetype_e getFileType(std::string filespec);
+//    filetype_e getFileType(std::string &filespec);
+    filetype_e getFileType(std::string &filespec);
     void dump();
 
     // These accessors are used mostly just for debugging.
     bool keepAlive() { return _keepalive; }
+    int getFileSize() { return _filesize; }
     std::string getFilespec() { return _filespec; }
     std::string getURL() { return _url; }
     std::map<int, struct status_codes *> getStatusCodes()
@@ -183,11 +196,12 @@
     std::string getHost() { return _host; }
     std::string getUserAgent() { return _agent; }
     
-
 private:
     std::stringstream _header;
+    std::stringstream _body;
     filetype_e  _filetype;
     std::string _filespec;
+    int         _filesize;
     std::string _url;
     std::map<int, struct status_codes *> _status_codes;
     std::string _version;

Index: cygnal/testsuite/cygnal.all/test_crc.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/testsuite/cygnal.all/test_crc.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cygnal/testsuite/cygnal.all/test_crc.cpp    12 Dec 2007 23:56:30 -0000      
1.1
+++ cygnal/testsuite/cygnal.all/test_crc.cpp    13 Dec 2007 19:46:33 -0000      
1.2
@@ -51,6 +51,7 @@
 using namespace cygnal;
 
 TestState runtest;
+LogFile& dbglogfile = LogFile::getDefaultInstance();
 
 int
 main (int /*argc*/, char** /*argv*/) {

Index: cygnal/testsuite/cygnal.all/test_http.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/testsuite/cygnal.all/test_http.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- cygnal/testsuite/cygnal.all/test_http.cpp   13 Dec 2007 00:54:29 -0000      
1.4
+++ cygnal/testsuite/cygnal.all/test_http.cpp   13 Dec 2007 19:46:33 -0000      
1.5
@@ -48,10 +48,10 @@
 
 static void usage (void);
 
-static int verbosity;
-
 static TestState runtest;
 
+LogFile& dbglogfile = LogFile::getDefaultInstance();
+
 int
 main(int argc, char *argv[])
 {
@@ -64,7 +64,7 @@
             break;
             
           case 'v':
-            verbosity++;
+              dbglogfile.setVerbosity();
             break;
             
           default:
@@ -123,6 +123,19 @@
     }
     regfree(&regex_pat);
 
+    // Check the Server field
+    http.clearHeader();
+    http.formatServer();
+//    cerr << "FIXME: " << http.getHeader() << endl;
+    regcomp (&regex_pat, "Server: Cygnal (GNU/Linux)$",
+             REG_NOSUB|REG_NEWLINE);
+    if (regexec (&regex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0)) 
{
+        runtest.fail ("HTTP::formatServer()");
+    } else {
+        runtest.pass ("HTTP::formatServer()");
+    }
+    regfree(&regex_pat);
+
     // Check the Host field
 //     bool formatHost(const char *data);
     http.clearHeader();
@@ -222,7 +235,7 @@
     if (regexec (&regex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0)) 
{
         runtest.fail ("HTTP::formatContentType(type)");
     } else {
-        runtest.pass ("HTTP::formatConetnType(type)");
+        runtest.pass ("HTTP::formatContentType(type)");
     }
     regfree(&regex_pat);
 
@@ -265,9 +278,32 @@
     }
     regfree(&regex_pat);
 
+    // Check the Server field
+    http.clearHeader();
+    http.formatErrorResponse(HTTP::NOT_FOUND);
+//    cerr << "FIXME: " << http.getHeader() << endl;
+//    cerr << "FIXME: " << http.getBody() << endl;
+    regcomp (&regex_pat, 
"Date:.*Server:.*Content-Length:.*Connection:.*Content-Type:.*$",
+             REG_NOSUB);        // note that we do want to look for NL
+    if (regexec (&regex_pat, http.getHeader().c_str(), 0, (regmatch_t *)0, 0)) 
{
+        runtest.fail ("HTTP::formatErrorResponse(header)");
+    } else {
+        runtest.pass ("HTTP::formatErrorResponse(header)");
+    }
+    regfree(&regex_pat);
+    regcomp (&regex_pat, "DOCTYPE.*<title>404 Not Found</title>.*$",
+             REG_NOSUB);        // note that we do want to look for NL
+    if (regexec (&regex_pat, http.getBody().c_str(), 0, (regmatch_t *)0, 0)) {
+        runtest.fail ("HTTP::formatErrorResponse(body)");
+    } else {
+        runtest.pass ("HTTP::formatErrorResponse(body)");
+    }
+    regfree(&regex_pat);
+    
     //
     // Decoding tests for HTTP
     //
+    http.clearHeader();
     const char *buffer = "GET 
/software/gnash/tests/flvplayer.swf?file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv
 HTTP/1.1\r\n"
 "User-Agent: Gnash/0.8.1-cvs (X11; Linux i686; U; en)\r\n"
 "Host: localhost:4080\r\n"
@@ -282,6 +318,18 @@
 "TE: deflate, gzip, chunked, identity, trailers\r\n"
 "\r\n";
     
+// GET /software/gnash/tests/ HTTP/1.1
+// Host: localhost:4080
+// User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.5) 
Gecko/20070718 Fedora/2.0.0.5-1.fc7 Firefox/2.0.0.5
+// Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
+// Accept-Language: en-us,en;q=0.5
+// Accept-Encoding: gzip,deflate
+// Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
+// Keep-Alive: 300
+// Connection: keep-alive
+
+// User Agent: Lynx/2.8.6rel.2 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8b
+    
 // Some browsers have a different synatax, of course, to keep things
 // interesting.
     const char *buffer2 = "GET 
/software/gnash/tests/flvplayer.swf?file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv
 HTTP/1.1\r\n"
@@ -313,7 +361,7 @@
     int count;
     count = http.extractLanguage(buffer);
     std::vector<std::string> language = http.getLanguage();
-    if ((count == 2) &&
+    if ((count > 2) &&
         (language[0] == "en-US") &&
         (language[1] == "en")) {
         runtest.fail ("HTTP::extractLanguage(Accept-)");
@@ -401,6 +449,11 @@
 //     }
 
 //    delete num;
+
+    
+    if (dbglogfile.getVerbosity() > 0) {
+        http.dump();
+    }
 }
 static void
 usage (void)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]