TWebFile.h

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TWebFile.h 34712 2010-08-03 09:27:19Z rdm $
00002 // Author: Fons Rademakers   17/01/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TWebFile
00013 #define ROOT_TWebFile
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TWebFile                                                             //
00019 //                                                                      //
00020 // A TWebFile is like a normal TFile except that it reads its data      //
00021 // via a standard apache web server. A TWebFile is a read-only file.    //
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;             // file size
00046    TSocket          *fSocket;           // socket for HTTP/1.1 (stays alive between calls)
00047    TUrl              fProxy;            // proxy URL
00048    Bool_t            fHasModRoot;       // true if server has mod_root installed
00049    Bool_t            fHTTP11;           // true if server support HTTP/1.1
00050    Bool_t            fNoProxy;          // don't use proxy
00051    TString           fMsgReadBuffer;    // cache ReadBuffer() msg
00052    TString           fMsgReadBuffer10;  // cache ReadBuffer10() msg
00053    TString           fMsgGetHead;       // cache GetHead() msg
00054    TString           fBasicUrl;         // basic url without authentication and options
00055    TUrl              fUrlOrg;           // save original url in case of temp redirection
00056    TString           fBasicUrlOrg;      // save original url in case of temp redirection
00057 
00058    static TUrl       fgProxy;           // globally set proxy URL
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)  //A ROOT file that reads via a http server
00091 };
00092 
00093 
00094 class TWebSystem : public TSystem {
00095 
00096 private:
00097    void *fDirp;    // directory handler
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)  // Directory handler for HTTP (TWebFiles)
00114 };
00115 
00116 #endif

Generated on Tue Jul 5 14:28:30 2011 for ROOT_528-00b_version by  doxygen 1.5.1