27 #include <netinet/in.h>
28 #include <arpa/inet.h>
33 #include <tqptrlist.h>
34 #include <tqstrlist.h>
35 #include <tqstringlist.h>
38 #include "tdeio/tcpslavebase.h"
39 #include "tdeio/http.h"
49 class HTTPProtocol :
public TQObject,
public TDEIO::TCPSlaveBase
53 HTTPProtocol(
const TQCString &protocol,
const TQCString &pool,
54 const TQCString &app );
55 virtual ~HTTPProtocol();
58 enum HTTP_REV {HTTP_None, HTTP_Unknown, HTTP_10, HTTP_11, SHOUTCAST};
61 enum HTTP_AUTH {AUTH_None, AUTH_Basic, AUTH_NTLM, AUTH_Digest, AUTH_Negotiate};
79 TQString encoded_hostname;
80 short unsigned int port;
106 method = TDEIO::HTTP_UNKNOWN;
109 allowCompressedPage =
false;
110 disablePassDlg =
false;
114 bCachedWrite =
false;
116 bMustRevalidate =
false;
117 cacheExpireDateOffset = 0;
119 bUseCookiejar =
false;
125 TQString encoded_hostname;
126 short unsigned int port;
131 TDEIO::HTTP_METHOD method;
132 TDEIO::CacheControl cache;
133 TDEIO::filesize_t offset;
140 bool allowCompressedPage;
155 TQString lastModified;
156 bool bMustRevalidate;
157 long cacheExpireDateOffset;
168 enum { CookiesAuto, CookiesManual, CookiesNone } cookieMode;
171 struct DigestAuthInfo
183 TQCString entityBody;
187 virtual void setHost(
const TQString& host,
int port,
const TQString& user,
188 const TQString& pass);
190 virtual void slave_status();
192 virtual void get(
const KURL& url );
193 virtual void put(
const KURL& url,
int permissions,
bool overwrite,
197 virtual void listDir(
const KURL& url );
198 virtual void mkdir(
const KURL& url,
int permissions );
200 virtual void rename(
const KURL& src,
const KURL& dest,
bool overwrite );
201 virtual void copy(
const KURL& src,
const KURL& dest,
int permissions,
bool overwrite );
202 virtual void del(
const KURL& url,
bool isfile );
208 void davGeneric(
const KURL& url, TDEIO::HTTP_METHOD method );
211 void davLock(
const KURL& url,
const TQString& scope,
212 const TQString& type,
const TQString& owner );
213 void davUnlock(
const KURL& url );
219 TQString davError(
int code = -1, TQString url = TQString::null );
231 virtual void special(
const TQByteArray &data );
233 virtual void mimetype(
const KURL& url);
235 virtual void stat(
const KURL& url );
237 virtual void reparseConfiguration();
239 virtual void closeConnection();
241 void post(
const KURL& url );
242 void multiGet(
const TQByteArray &data);
243 bool checkRequestURL(
const KURL& );
244 void cacheUpdate(
const KURL &url,
bool nocache, time_t expireDate);
248 bool isOffline(
const KURL &url);
251 void slotData(
const TQByteArray &);
252 void error(
int _errid,
const TQString &_text );
265 ssize_t write(
const void *buf,
size_t nbytes);
272 ssize_t read (
void *b,
size_t nbytes);
274 char *gets (
char *str,
int size);
276 void setRewindMarker();
284 void addEncoding(TQString, TQStringList &);
286 void configAuth(
char *,
bool );
289 void httpClose(
bool keepAlive);
291 bool httpOpenConnection();
292 void httpCloseConnection();
293 void httpCheckConnection();
295 void forwardHttpResponseHeader();
303 bool readBody(
bool dataInternal =
false );
308 void davSetRequest(
const TQCString& requestXML );
309 void davStatList(
const KURL& url,
bool stat =
true );
310 void davParsePropstats(
const TQDomNodeList& propstats, TDEIO::UDSEntry& entry );
311 void davParseActiveLocks(
const TQDomNodeList& activeLocks,
317 long parseDateTime(
const TQString& input,
const TQString& type );
322 int codeFromResponse(
const TQString& response );
328 TQString davProcessLocks();
333 void addCookies(
const TQString &url,
const TQCString &cookieHeader);
338 TQString findCookies(
const TQString &url);
351 FILE *checkCacheEntry(
bool readWrite =
false);
358 void createCacheEntry(
const TQString &mimetype, time_t expireDate);
365 void writeCacheEntry(
const char *buffer,
int nbytes);
370 void closeCacheEntry();
375 void updateExpireDate(time_t expireDate,
bool updateCreationDate=
false);
387 void retrieveContent(
bool dataInternal =
false );
392 bool retrieveHeader(
bool close_connection =
true);
397 void resetSessionSettings();
402 void resetResponseSettings();
410 void resetConnectionSettings();
416 TQString proxyAuthenticationHeader();
421 bool getAuthorization();
426 void saveAuthorization();
431 TQString createBasicAuth(
bool isForProxy =
false );
436 TQString createDigestAuth(
bool isForProxy =
false );
441 TQString createNTLMAuth(
bool isForProxy =
false );
446 TQString createNegotiateAuth();
451 TQCString gssError(
int major_status,
int minor_status );
456 void calculateResponse( DigestAuthInfo &info, TQCString &Response );
466 void promptInfo( TDEIO::AuthInfo& info );
470 HTTPRequest m_request;
471 TQPtrList<HTTPRequest> m_requestQueue;
478 TQStringList m_responseHeader;
479 KURL m_redirectLocation;
484 TDEIO::filesize_t m_iSize;
485 TDEIO::filesize_t m_iBytesLeft;
486 TDEIO::filesize_t m_iContentLeft;
487 TQByteArray m_bufReceive;
489 char m_lineBuf[1024];
490 char m_rewindBuf[8192];
491 size_t m_rewindCount;
494 char *m_lineBufUnget;
495 char *m_linePtrUnget;
496 size_t m_lineCountUnget;
500 TQByteArray m_mimeTypeBuffer;
503 TQStringList m_qTransferEncodings;
504 TQStringList m_qContentEncodings;
505 TQString m_sContentMD5;
506 TQString m_strMimeType;
511 TQByteArray m_bufWebDavData;
512 TQStringList m_davCapabilities;
515 bool m_davHostUnsupported;
521 TQByteArray m_bufPOST;
526 TQString m_strCacheDir;
534 bool m_bProxyAuthValid;
537 TQString m_strProxyRealm;
540 TQCString m_protocol;
544 TQString m_strAuthorization;
545 TQString m_strProxyAuthorization;
546 HTTP_AUTH Authentication;
547 HTTP_AUTH ProxyAuthentication;
548 bool m_bUnauthorized;
549 short unsigned int m_iProxyAuthCount;
550 short unsigned int m_iWWWAuthCount;
553 bool m_bFirstRequest;
557 int m_keepAliveTimeout;
560 bool m_bPersistentProxyConnection;
567 unsigned int m_responseCode;
568 unsigned int m_prevResponseCode;
571 int m_proxyConnTimeout;
572 int m_remoteConnTimeout;
573 int m_remoteRespTimeout;
DAV-specific request elements for the current connection.
The request for the current connection.