TWinInet - Exemples

TWinInet = class (TObject)Interface de TWinInetExemples de TWinInet
uses Networking, Interactive;

var http := new TWinInet;

// Activation de la décompression HTTP
http.HttpDecoding:=True;

// Contexte
http.Referrer:='http://www.mondomaine.fr';
http.UserAgent:='MonUserAgent';

// Réglages du proxy
http.BypassProxy:=False;
http.ProxyUser:='MonLoginProxy';
http.ProxyPass:='MonPassProxy';

// Authentification auprès du serveur
http.AuthUser:='MonLogin';
http.AuthPass:='MonPass';

// Ajout de headers supplémentaires
var lst := new TStrings;
lst.Add('If-Modified-Since: Tue, 06 Nov 2012 11:53:35 GMT');
lst.Add('Accept: text/plain');
http.RequestHeaders:=lst.CommaText;

http.RequestTimeOut:=1000;

http.GetRequest('http://www.google.fr');

// Si la réponse est OK et contient du HTML, on l'affiche
if (http.StatusCode=200) and (Pos('text/html', http.ContentType)>0) then
   HTMLBox(http.ContentAsText, 800, 600);