diff options
author | thlo <t.lohmar@gmx.de> | 2012-12-25 11:36:09 +0100 |
---|---|---|
committer | thlo <t.lohmar@gmx.de> | 2012-12-25 11:36:09 +0100 |
commit | 6399355d20ee87365e19ef94aa8798c602f697e6 (patch) | |
tree | 43fc29789e9eef0e153e7e71ce57c197587cd82c /vdr-smarttvweb/httpresource-hmm.h | |
download | vdr-plugin-smarttvweb-6399355d20ee87365e19ef94aa8798c602f697e6.tar.gz vdr-plugin-smarttvweb-6399355d20ee87365e19ef94aa8798c602f697e6.tar.bz2 |
Initial Version
Diffstat (limited to 'vdr-smarttvweb/httpresource-hmm.h')
-rw-r--r-- | vdr-smarttvweb/httpresource-hmm.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/vdr-smarttvweb/httpresource-hmm.h b/vdr-smarttvweb/httpresource-hmm.h new file mode 100644 index 0000000..543377d --- /dev/null +++ b/vdr-smarttvweb/httpresource-hmm.h @@ -0,0 +1,94 @@ + +#ifndef __HTTPREQUEST_H__ +#define __HTTPREQUEST_H__ + +#include <string> +#include <cstring> +#include <pthread.h> +#include "log.h" + +using namespace std; + +struct cRange { +cRange(): isRangeRequest(false), begin(0), end(0) {}; + bool isRangeRequest; + unsigned long long begin; + unsigned long long end; +}; + +enum eConnState { + WAITING, + SERVING, + TOCLOSE +}; + +class cHttpResource { + + public: + cHttpResource(int, int, string, int); + virtual ~cHttpResource(); + + int readFromClient(); + // int sendNextChunk(); + void threadLoop(); + int run(); + + private: + Log* mLog; + pthread_t mThreadId; + pthread_mutex_t mSendLock; + string mServerAddr; + int mServerPort; + int mFd; + int mReqId; + + bool mConnected; + eConnState mConnState; + string mMethod; + char *mDataBuffer; + bool mBlkData; + int mBlkPos; + int mBlkLen; + + // string path; + string mPath; + string mVersion; + string protocol; + + bool mAcceptRanges; + cRange rangeHdr; + unsigned long long mFileSize; + uint mRemLength; + FILE *mFile; + + + // int tcpServerWrite(const char buf[], int buflen); + int writeToClient(const char *buf, size_t buflen); + int sendDataChunk(); + + void setNonBlocking(); + + int processHttpHeaderNew(); + // int processHttpHeader(); + void sendError(int status, const char *title, const char *extra, const char *text); + int sendDir(struct stat *statbuf); + int sendVdrDir(struct stat *statbuf); + int sendRecordingsHtml (struct stat *statbuf); + int sendRecordingsXml (struct stat *statbuf); + string removeEtChar(string line); + + void sendHeaders(int status, const char *title, const char *extra, const char *mime, + off_t length, time_t date); + + int sendFirstChunk(struct stat *statbuf); + + // Helper Functions + char *getMimeType(const char *name); + string getConnStateName(); + int parseRangeHeaderValue(string); + int openFile(const char *name); + string hexDump(string in); + string iso8859ToUtf8 (string); + +}; +#endif |