• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

http_server.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 //
00018 
00019 #ifndef _HTTP_SERVER_H_
00020 #define _HTTP_SERVER_H_
00021 
00022 #include <string>
00023 #include <vector>
00024 #include <boost/shared_ptr.hpp>
00025 #include <boost/shared_array.hpp>
00026 #include <boost/scoped_array.hpp>
00027 #include <sstream>
00028 
00029 #include "amf.h"
00030 #include "cque.h"
00031 #include "rtmp.h"
00032 #include "http.h"
00033 #include "handler.h"
00034 #include "network.h"
00035 #include "buffer.h"
00036 #include "diskstream.h"
00037 
00038 namespace cygnal
00039 {
00040     
00041 class DSOEXPORT HTTPServer : public gnash::HTTP
00042 {
00043 public:
00044     HTTPServer();
00045     ~HTTPServer();
00046 
00047     // These are for the protocol itself
00048     http_method_e processClientRequest(int fd);
00049     http_method_e processClientRequest(Handler *hand, int fd, cygnal::Buffer *buf);
00050     cygnal::Buffer &processGetRequest(Handler *hand, int fd, cygnal::Buffer *buf);
00051     boost::shared_ptr<cygnal::Buffer> processPostRequest(int fd, cygnal::Buffer *buf);
00052     boost::shared_ptr<cygnal::Buffer> processPutRequest(int fd, cygnal::Buffer *buf);
00053     boost::shared_ptr<cygnal::Buffer> processDeleteRequest(int fd, cygnal::Buffer *buf);
00054     boost::shared_ptr<cygnal::Buffer> processConnectRequest(int fd, cygnal::Buffer *buf);
00055     boost::shared_ptr<cygnal::Buffer> processOptionsRequest(int fd, cygnal::Buffer *buf);
00056     boost::shared_ptr<cygnal::Buffer> processHeadRequest(int fd, cygnal::Buffer *buf);
00057     boost::shared_ptr<cygnal::Buffer> processTraceRequest(int fd, cygnal::Buffer *buf);
00058 
00059     // Handle the response for the request.
00060     boost::shared_ptr<cygnal::Buffer> formatServerReply(http_status_e code);
00061     cygnal::Buffer &formatGetReply(gnash::DiskStream::filetype_e type, size_t size, http_status_e code); 
00062     cygnal::Buffer &formatGetReply(size_t size, http_status_e code); 
00063     cygnal::Buffer &formatGetReply(http_status_e code); 
00064     cygnal::Buffer &formatPostReply(rtmpt_cmd_e code);
00065     cygnal::Buffer &formatErrorResponse(http_status_e err);
00066 
00067     // These methods extract data from an RTMPT message. RTMP is an
00068     // extension to HTTP that adds commands to manipulate the
00069     // connection's persistance.
00070     rtmpt_cmd_e extractRTMPT(boost::uint8_t *data);
00071     rtmpt_cmd_e extractRTMPT(cygnal::Buffer &data)
00072         { return extractRTMPT(data.reference()); };    
00073 
00074 #if 0
00075     // Examine the beginning of the data for an HTTP request command
00076     // like GET or POST, etc...
00077     http_method_e extractCommand(boost::uint8_t *data);
00078     http_method_e extractCommand(cygnal::Buffer &data)
00079         { return extractCommand(data.reference()); };    
00080 
00081     // process all the header fields in the Buffer, storing them internally
00082     // in _fields. The address returned is the address where the Content data
00083     // starts, and is "Content-Length" bytes long, of "Content-Type" data.
00084     boost::uint8_t *processHeaderFields(cygnal::Buffer &buf);
00085 #endif
00086     
00087 #if 0
00088     // Parse an Echo Request message coming from the Red5 echo_test.
00089     std::vector<boost::shared_ptr<cygnal::Element > > parseEchoRequest(gnash::cygnal::Buffer &buf) { return parseEchoRequest(buf.reference(), buf.size()); };
00090     std::vector<boost::shared_ptr<cygnal::Element > > parseEchoRequest(boost::uint8_t *buf, size_t size);
00091     
00092     // format a response to the 'echo' test used for testing Gnash.
00093     gnash::cygnal::Buffer &formatEchoResponse(const std::string &num, cygnal::Element &el);
00094     gnash::cygnal::Buffer &formatEchoResponse(const std::string &num, cygnal::Buffer &data);
00095     gnash::cygnal::Buffer &formatEchoResponse(const std::string &num, uint8_t *data, size_t size);
00096 #endif
00097 
00098     bool http_handler(Handler *hand, int netfd, cygnal::Buffer *buf);
00099     boost::shared_ptr<gnash::DiskStream> getDiskStream() { return _diskstream; };
00100 
00101     void dump();    
00102 private:
00103     boost::shared_ptr<gnash::DiskStream> _diskstream;
00104 };
00105 
00106 } // end of gnash namespace
00107 
00108 // end of _HTTP_SERVER_H_
00109 #endif
00110 
00111 
00112 // local Variables:
00113 // mode: C++
00114 // indent-tabs-mode: t
00115 // End:

Generated on Thu Sep 30 2010 14:34:59 for Gnash by  doxygen 1.7.1