00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TWebFile
00013 #define ROOT_TWebFile
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_TFile
00026 #include "TFile.h"
00027 #endif
00028 #ifndef ROOT_TUrl
00029 #include "TUrl.h"
00030 #endif
00031 #ifndef ROOT_TSystem
00032 #include "TSystem.h"
00033 #endif
00034
00035 class TSocket;
00036 class TWebSocket;
00037
00038
00039 class TWebFile : public TFile {
00040
00041 friend class TWebSocket;
00042 friend class TWebSystem;
00043
00044 private:
00045 mutable Long64_t fSize;
00046 TSocket *fSocket;
00047 TUrl fProxy;
00048 Bool_t fHasModRoot;
00049 Bool_t fHTTP11;
00050 Bool_t fNoProxy;
00051 TString fMsgReadBuffer;
00052 TString fMsgReadBuffer10;
00053 TString fMsgGetHead;
00054 TString fBasicUrl;
00055 TUrl fUrlOrg;
00056 TString fBasicUrlOrg;
00057
00058 static TUrl fgProxy;
00059
00060 TWebFile() : fSocket(0) { }
00061 void Init(Bool_t readHeadOnly);
00062 void CheckProxy();
00063 TString BasicAuthentication();
00064 Int_t GetHead();
00065 Int_t GetLine(TSocket *s, char *line, Int_t maxsize);
00066 Int_t GetHunk(TSocket *s, char *hunk, Int_t maxsize);
00067 const char *HttpTerminator(const char *start, const char *peeked, Int_t peeklen);
00068 Int_t GetFromWeb(char *buf, Int_t len, const TString &msg);
00069 Int_t GetFromWeb10(char *buf, Int_t len, const TString &msg);
00070 Bool_t ReadBuffer10(char *buf, Int_t len);
00071 Bool_t ReadBuffers10(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
00072 void SetMsgReadBuffer10(const char *redirectLocation = 0, Bool_t tempRedirect = kFALSE);
00073
00074 public:
00075 TWebFile(const char *url, Option_t *opt="");
00076 TWebFile(TUrl url, Option_t *opt="");
00077 virtual ~TWebFile();
00078
00079 Long64_t GetSize() const;
00080 Bool_t IsOpen() const;
00081 Int_t ReOpen(Option_t *mode);
00082 Bool_t ReadBuffer(char *buf, Int_t len);
00083 Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
00084 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
00085 void Seek(Long64_t offset, ERelativeTo pos = kBeg);
00086
00087 static void SetProxy(const char *url);
00088 static const char *GetProxy();
00089
00090 ClassDef(TWebFile,2)
00091 };
00092
00093
00094 class TWebSystem : public TSystem {
00095
00096 private:
00097 void *fDirp;
00098
00099 void *GetDirPtr() const { return fDirp; }
00100
00101 public:
00102 TWebSystem();
00103 virtual ~TWebSystem() { }
00104
00105 Int_t MakeDirectory(const char *name);
00106 void *OpenDirectory(const char *name);
00107 void FreeDirectory(void *dirp);
00108 const char *GetDirEntry(void *dirp);
00109 Int_t GetPathInfo(const char *path, FileStat_t &buf);
00110 Bool_t AccessPathName(const char *path, EAccessMode mode);
00111 Int_t Unlink(const char *path);
00112
00113 ClassDef(TWebSystem,0)
00114 };
00115
00116 #endif