gnash-commit
[Top][All Lists]
Advanced

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

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


From: Rob Savoye
Subject: [Gnash-commit] gnash/cygnal http.h http.cpp ChangeLog
Date: Tue, 18 Mar 2008 19:54:56 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    08/03/18 19:54:56

Modified files:
        cygnal         : http.h http.cpp ChangeLog 

Log message:
                * http.cpp: Use Network::byte_t instead of boost_uint8_t. Use a
                Buffer too.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/http.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/cygnal/ChangeLog?cvsroot=gnash&r1=1.7&r2=1.8

Patches:
Index: http.h
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- http.h      18 Mar 2008 01:06:04 -0000      1.14
+++ http.h      18 Mar 2008 19:54:55 -0000      1.15
@@ -33,7 +33,7 @@
 namespace cygnal
 {
     
-class HTTP : public Handler
+class HTTP
 {
 public:
 // as defined by the W3: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
@@ -113,6 +113,7 @@
        OSCP
     } filetype_e;
     HTTP();
+    HTTP(Handler *hand);
     ~HTTP();
     std::string waitForGetRequest();
     std::string waitForGetRequest(gnash::Network &net);
@@ -126,18 +127,38 @@
 
     // 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);
+    int extractAccept(gnash::Network::byte_t *data);
+    int extractAccept(Buffer *data)
+       { return extractAccept(data->reference()); };
+    int extractLanguage(gnash::Network::byte_t *data);
+    int extractLanguage(Buffer *data)
+       { return extractLanguage(data->reference()); };
+    int extractCharset(gnash::Network::byte_t *data);
+    int extractCharset(Buffer *data)
+       { return extractCharset(data->reference()); };
+    int extractEncoding(gnash::Network::byte_t *data);
+    int extractEncoding(Buffer *data)
+       { return extractEncoding(data->reference()); };
+    int extractTE(gnash::Network::byte_t *data);
+    int extractTE(Buffer *data)
+       { return extractTE(data->reference()); };
+    int extractConnection(gnash::Network::byte_t *data);
+    int extractConnection(Buffer *data)
+       { return extractConnection(data->reference()); };
 
     // These return the string that was found for this field.
-    std::string extractMethod(const char *data);
-    std::string extractReferer(const char *data);
-    std::string extractHost(const char *data);
-    std::string extractAgent(const char *data);
+    std::string extractMethod(gnash::Network::byte_t *data);
+    std::string extractMethod(Buffer *data)
+       { return extractMethod(data->reference()); };
+    std::string extractReferer(gnash::Network::byte_t *data);
+    std::string extractReferer(Buffer *data)
+       { return extractReferer(data->reference()); };
+    std::string extractHost(gnash::Network::byte_t *data);
+    std::string extractHost(Buffer *data)
+       { return extractHost(data->reference()); };
+    std::string extractAgent(gnash::Network::byte_t *data);
+    std::string extractAgent(Buffer *data)
+       { return extractAgent(data->reference()); };
 
     // These methods add data to the fields in the HTTP header.
     // These return true if OK, false if error.
@@ -199,6 +220,7 @@
     std::string getHost() { return _host; }
     std::string getUserAgent() { return _agent; }
 
+    void setHandler(Handler *hand) { _handler = hand; };
 private:
     std::stringstream _header;
     std::stringstream _body;
@@ -221,6 +243,7 @@
     std::vector<std::string> _accept;
     // Connection parameters we care about
     bool       _keepalive;
+    Handler     *_handler;
 //    bool     _te;
 };  
 

Index: http.cpp
===================================================================
RCS file: /sources/gnash/gnash/cygnal/http.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- http.cpp    18 Mar 2008 01:06:04 -0000      1.18
+++ http.cpp    18 Mar 2008 19:54:56 -0000      1.19
@@ -31,9 +31,10 @@
 #include <cstring>
 #include <sys/types.h>
 #include <sys/stat.h>
+
 #include "http.h"
 #include "log.h"
-
+#include "network.h"
 #include "handler.h"
 
 using namespace gnash;
@@ -48,7 +49,7 @@
 static const int readsize = 1024;
 
 HTTP::HTTP() 
-    : _filesize(0), _port(80), _keepalive(false)
+    : _filesize(0), _port(80), _keepalive(false), _handler(0)
 {
 //    GNASH_REPORT_FUNCTION;
 //    struct status_codes *status = new struct status_codes;
@@ -56,6 +57,13 @@
 //    _status_codes(CONTINUE, status);
 }
 
+HTTP::HTTP(Handler *hand) 
+    : _filesize(0), _port(80), _keepalive(false)
+{
+//    GNASH_REPORT_FUNCTION;
+    _handler = hand;
+}
+
 HTTP::~HTTP()
 {
 //    GNASH_REPORT_FUNCTION;
@@ -97,34 +105,39 @@
 {
     GNASH_REPORT_FUNCTION;
 
-    byte_t buffer[readsize+1];
-    const char *ptr = reinterpret_cast<const char *>(buffer);
-    memset(buffer, 0, readsize+1);
-    if (readNet(buffer, readsize) > 0) {
-        log_debug (_("Read initial GET Request"));
-    } else {
-        log_error (_("Couldn't read initial GET Request"));
-    }
+//     Network::byte_t buffer[readsize+1];
+//     const char *ptr = reinterpret_cast<const char *>(buffer);
+//     memset(buffer, 0, readsize+1);
+    
+//    _handler->wait();
+    Buffer *buf = _handler->pop();
+
+//    const char *ptr = reinterpret_cast<const char *>(buf->reference());
+//     if (readNet(buffer, readsize) > 0) {
+//         log_debug (_("Read initial GET Request"));
+//     } else {
+//         log_error (_("Couldn't read initial GET Request"));
+//     }
 
     clearHeader();
-    extractAccept(ptr);
-    extractMethod(ptr);
-    extractReferer(ptr);
-    extractHost(ptr);
-    extractAgent(ptr);
-    extractLanguage(ptr);
-    extractCharset(ptr);
-    extractConnection(ptr);
-    extractEncoding(ptr);
-    extractTE(ptr);
+    extractAccept(buf);
+    extractMethod(buf);
+    extractReferer(buf);
+    extractHost(buf);
+    extractAgent(buf);
+    extractLanguage(buf);
+    extractCharset(buf);
+    extractConnection(buf);
+    extractEncoding(buf);
+    extractTE(buf);
     dump();
 
-    // See if we got a legit GET request
-    if (strncmp(ptr, "GET ", 4) == 0) {
-        log_debug (_("Got legit GET request"));
-    } else {
-        log_error (_("Got bogus GET request"));
-    }
+//     // See if we got a legit GET request
+//     if (strncmp(ptr, "GET ", 4) == 0) {
+//         log_debug (_("Got legit GET request"));
+//     } else {
+//         log_error (_("Got bogus GET request"));
+//     }
 
     _filespec = _url;
     return _url;
@@ -358,19 +371,25 @@
     GNASH_REPORT_FUNCTION;
     
     formatHeader(_filesize, HTML);
-    int ret = Network::writeNet(_header.str());
-    if ( _body.str().size() > 0) {
-       ret += Network::writeNet(_body.str());
-    }
+//    int ret = Network::writeNet(_header.str());
+    Buffer *buf = new Buffer;
+    Network::byte_t *ptr = (Network::byte_t *)_body.str().c_str();
+    buf->copy(ptr, _body.str().size());
+    buf->resize(_body.str().size());
+    _handler->pushout(buf);
+    _handler->notifyout();
+//     if ( _body.str().size() > 0) {
+//     ret += Network::writeNet(_body.str());
+//     }
 
-    if (ret >= 0) {
+//    if (ret >= 0) {
         log_debug (_("Sent GET Reply"));
 //        log_debug (_("Sent GET Reply: %s"), _header.str().c_str());
        clearHeader();
-    } else {
-        log_debug (_("Couldn't send GET Reply, writeNet returned %d"), ret);
-       return false;
-    }
+//     } else {
+//         log_debug (_("Couldn't send GET Reply, writeNet returned %d"), ret);
+//     return false;
+//     }
 //    cout << "GET Header is:" << endl << _header.str() << endl;
     return true; // Default to true
 }
@@ -414,10 +433,10 @@
 // Connection: Keep-Alive, TE
 // TE: deflate, gzip, chunked, identity, trailers
 int
-HTTP::extractAccept(const char *data) {
+HTTP::extractAccept(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end, length, pos;
     string pattern = "Accept: ";
     
@@ -454,11 +473,11 @@
 }
 
 string
-HTTP::extractMethod(const char *data) {
+HTTP::extractMethod(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
     boost::mutex::scoped_lock lock(stl_mutex);
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end;
     int length;
 
@@ -481,10 +500,10 @@
 }
 
 string 
-HTTP::extractReferer(const char *data) {
+HTTP::extractReferer(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end;
     string pattern = "Referer: ";
     
@@ -502,10 +521,10 @@
 }
 
 int
-HTTP::extractConnection(const char *data) {
+HTTP::extractConnection(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end, length, pos;
     string pattern = "Connection: ";
     
@@ -546,10 +565,10 @@
 }
 
 string
-HTTP::extractHost(const char *data) {
+HTTP::extractHost(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end;
     string pattern = "Host: ";
     
@@ -567,10 +586,10 @@
 }
 
 string 
-HTTP::extractAgent(const char *data) {
+HTTP::extractAgent(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end;
     string pattern = "User-Agent: ";
     
@@ -588,10 +607,10 @@
 }
 
 int
-HTTP::extractLanguage(const char *data) {
+HTTP::extractLanguage(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end, length, pos, terminate;
     // match both Accept-Language and Content-Language
     string pattern = "-Language: ";
@@ -634,10 +653,10 @@
 }
 
 int
-HTTP::extractCharset(const char *data) {
+HTTP::extractCharset(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end, length, pos, terminate;
 // match both Accept-Charset and Content-Charset
     string pattern = "-Charset: ";
@@ -680,10 +699,10 @@
 }
 
 int
-HTTP::extractEncoding(const char *data) {
+HTTP::extractEncoding(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end, length, pos, terminate;
     // match both Accept-Encoding and Content-Encoding
     string pattern = "-Encoding: ";
@@ -728,10 +747,10 @@
 }
 
 int
-HTTP::extractTE(const char *data) {
+HTTP::extractTE(Network::byte_t *data) {
 //    GNASH_REPORT_FUNCTION;
     
-    string body = data;
+    string body = reinterpret_cast<const char *>(data);
     string::size_type start, end, length, pos;
     string pattern = "TE: ";
     
@@ -867,11 +886,13 @@
 {
     GNASH_REPORT_FUNCTION;
     int retries = 10;
-    HTTP www;
 //    struct thread_params thread_data;
     string url, filespec, parameters;
     string::size_type pos;
     Handler *hand = reinterpret_cast<Handler *>(args->handle);
+    HTTP www;
+    www.setHandler(hand);
+    
 //    hand->_outcond.wait();
 
 //     www.toggleDebug(true);
@@ -885,7 +906,7 @@
        
 //     conndata->statistics->setFileType(NetStats::RTMPT);
 //     conndata->statistics->startClock();
-       args->netfd = www.getFileFd();
+//     args->netfd = www.getFileFd();
        url = docroot;
        url += www.waitForGetRequest();
        pos = url.find("?");

Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/cygnal/ChangeLog,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- ChangeLog   18 Mar 2008 01:06:03 -0000      1.7
+++ ChangeLog   18 Mar 2008 19:54:56 -0000      1.8
@@ -1,3 +1,8 @@
+2008-03-18  Rob Savoye  <address@hidden>
+
+       * http.cpp: Use Network::byte_t instead of boost_uint8_t. Use a
+       Buffer too.
+
 2008-03-17  Rob Savoye  <address@hidden>
 
        * alloc.cpp: Don't use thrrad safe wrappers for now.




reply via email to

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