File indexing completed on 2025-01-18 10:12:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TWebFile
0013 #define ROOT_TWebFile
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include "TFile.h"
0026 #include "TUrl.h"
0027 #include "TSystem.h"
0028
0029 class TSocket;
0030 class TWebSocket;
0031
0032
0033 class TWebFile : public TFile {
0034
0035 friend class TWebSocket;
0036 friend class TWebSystem;
0037
0038 private:
0039 TWebFile() : fSocket(nullptr) {}
0040
0041 protected:
0042 mutable Long64_t fSize;
0043 TSocket *fSocket;
0044 TUrl fProxy;
0045 Bool_t fHasModRoot;
0046 Bool_t fHTTP11;
0047 Bool_t fNoProxy;
0048 TString fMsgReadBuffer;
0049 TString fMsgReadBuffer10;
0050 TString fMsgGetHead;
0051 TString fBasicUrl;
0052 TUrl fUrlOrg;
0053 TString fBasicUrlOrg;
0054 void *fFullCache;
0055 Long64_t fFullCacheSize;
0056
0057 static TUrl fgProxy;
0058 static Long64_t fgMaxFullCacheSize;
0059
0060 void Init(Bool_t readHeadOnly) override;
0061 virtual void CheckProxy();
0062 virtual TString BasicAuthentication();
0063 virtual Int_t GetHead();
0064 virtual Int_t GetLine(TSocket *s, char *line, Int_t maxsize);
0065 virtual Int_t GetHunk(TSocket *s, char *hunk, Int_t maxsize);
0066 virtual const char *HttpTerminator(const char *start, const char *peeked, Int_t peeklen);
0067 virtual Int_t GetFromWeb(char *buf, Int_t len, const TString &msg);
0068 virtual Int_t GetFromWeb10(char *buf, Int_t len, const TString &msg, Int_t nseg = 0, Long64_t *seg_pos = nullptr, Int_t *seg_len = nullptr);
0069 virtual Int_t GetFromCache(char *buf, Int_t len, Int_t nseg, Long64_t *seg_pos, Int_t *seg_len);
0070 virtual Bool_t ReadBuffer10(char *buf, Int_t len);
0071 virtual Bool_t ReadBuffers10(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
0072 virtual void SetMsgReadBuffer10(const char *redirectLocation = nullptr, Bool_t tempRedirect = kFALSE);
0073 virtual void ProcessHttpHeader(const TString& headerLine);
0074
0075 public:
0076 TWebFile(const char *url, Option_t *opt="");
0077 TWebFile(TUrl url, Option_t *opt="");
0078 virtual ~TWebFile();
0079
0080 void Close(Option_t *option="") override;
0081 Long64_t GetSize() const override;
0082 Bool_t IsOpen() const override;
0083 Int_t ReOpen(Option_t *mode) override;
0084 Bool_t ReadBuffer(char *buf, Int_t len) override;
0085 Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override;
0086 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override;
0087 void Seek(Long64_t offset, ERelativeTo pos = kBeg) override;
0088
0089 static void SetProxy(const char *url);
0090 static const char *GetProxy();
0091
0092 static Long64_t GetMaxFullCacheSize();
0093 static void SetMaxFullCacheSize(Long64_t sz);
0094
0095 ClassDefOverride(TWebFile,2)
0096 };
0097
0098
0099 class TWebSystem : public TSystem {
0100
0101 private:
0102 void *fDirp;
0103
0104 void *GetDirPtr() const override { return fDirp; }
0105
0106 public:
0107 TWebSystem();
0108 virtual ~TWebSystem() {}
0109
0110 Int_t MakeDirectory(const char *name) override;
0111 void *OpenDirectory(const char *name) override;
0112 void FreeDirectory(void *dirp) override;
0113 const char *GetDirEntry(void *dirp) override;
0114 Int_t GetPathInfo(const char *path, FileStat_t &buf) override;
0115 Bool_t AccessPathName(const char *path, EAccessMode mode) override;
0116 Int_t Unlink(const char *path) override;
0117
0118 ClassDefOverride(TWebSystem,0)
0119 };
0120
0121 #endif