1 // 2 // This file is part of the aMule Project. 3 // 4 // Copyright (c) 2004-2011 shakraw ( shakraw@users.sourceforge.net ) 5 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 6 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net ) 7 // 8 // Any parts of this program derived from the xMule, lMule or eMule project, 9 // or contributed by third-party developers are copyrighted by their 10 // respective authors. 11 // 12 // This program is free software; you can redistribute it and/or modify 13 // it under the terms of the GNU General Public License as published by 14 // the Free Software Foundation; either version 2 of the License, or 15 // (at your option) any later version. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of the GNU General Public License 23 // along with this program; if not, write to the Free Software 24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 25 // 26 27 #ifndef WEBSOCKET_H 28 #define WEBSOCKET_H 29 30 31 #include "WebServer.h" 32 #include <LibSocket.h> 33 34 35 #ifdef ENABLE_UPNP 36 class CUPnPControlPoint; 37 class CUPnPPortMapping; 38 #endif 39 class CWebServer; 40 41 42 class CWebSocket : public CLibSocket { 43 public: 44 CWebSocket(CWebServerBase *parent); 45 46 virtual void OnSend(int); 47 virtual void OnReceive(int); 48 virtual void OnLost(); 49 50 void OnRequestReceived(char* pHeader, char* pData, uint32 dwDataLen); 51 52 void SendContent(const char* szStdResponse, const void* pContent, uint32 dwContentSize); 53 void SendData(const void* pData, uint32 dwDataSize); 54 void SendHttpHeaders(const char * szType, bool use_gzip, uint32 content_len, int session_id); 55 56 CWebServerBase *m_pParent; 57 58 class CChunk { 59 public: 60 char* m_pData; 61 char* m_pToSend; 62 uint32 m_dwSize; 63 64 CChunk* m_pNext; ~CChunk()65 ~CChunk() { if (m_pData) delete[] m_pData; } 66 }; 67 68 CChunk *m_pHead; // tails of what has to be sent 69 CChunk *m_pTail; 70 71 bool m_IsGet, m_IsPost; 72 char *m_Cookie; 73 char *m_pBuf; 74 uint32 m_dwBufSize; 75 uint32 m_dwRecv; 76 uint32 m_dwHttpHeaderLen; 77 uint32 m_dwHttpContentLen; 78 }; 79 80 #endif //WEBSERVER_H 81 // File_checked_for_headers 82