- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
function thttp.Get(URI: string): string;
var
newlocation:string;
redirect:integer;
contenttype:string;
i:integer;
contentencoding:string;
test:string;
host:string;
begin
redirect:=0;
headers.clear;
document.clear;
uri:=stringreplace(uri,'\','/',[rfreplaceall]);
// building the host///
if request.host <> '' then
headers.Add(format('Host:%s',[request.host]))
else
begin
i:=pos('://',uri);
if i>0 then
begin
host:=copy(uri,i+3,maxint);
i:=pos('/',host);
if i>0 then
host:=copy(host,1,i-1);
request.host:=host;
end
else
begin
i:=pos('/',uri);
if i>0 then host:=copy(uri,1,i-1)
else
host:=uri;
request.host:=host;
end;
end;
if request.referer <> '' then
headers.Add(format('Referer:%s',[request.referer]));
if request.useragent <> '' then
headers.Add(format('User-Agent:%s',[request.useragent]));
if request.AcceptEncoding <> '' then
headers.Add(format('Accept-Encoding:%s',[request.AcceptEncoding]));
if request.contenttype <> '' then
headers.Add('Content-Type:'+request.contenttype);
if request.connection <> '' then
headers.add('Connection:'+request.connection);
HTTPMethod('GET',uri);
if allowredirects=true then
begin
while (resultcode>=300) and (resultcode<400) do
begin
if (maxredirects <> -1) and (redirect > self.MaxRedirects) then break;
document.clear;
newlocation:=trim(Headers.Values['Location']);
if newlocation='' then break;
if (rightstr(request.host,1) <> '/') and (copy(newlocation,1,1) <> '/') then
newlocation:='/'+newlocation;
headers.clear;
document.clear;
HTTPMethod('GET',host+newlocation);
host:=trim(headers.Values['host']);
if host <> '' then
request.host:=host;
inc(redirect);
end;
end;
contenttype:=Headers.Values['Content-Type'];
contentencoding:=Headers.Values['Content-Encoding'];
request.contentencoding:=contentencoding;
request.contenttype:=contenttype;
if pos('gzip',ansilowercase(contentencoding))>0 then
begin
mstream.clear;
try
GZDecompressStream(Document, MStream);
document.Clear;
document.LoadFromStream(mstream);
document.Position:=0;
except
end;
end;
result:=memorystreamtostring(Document);
if pos('charset=utf-8',ansilowercase(contenttype))>0 then
test:=utf8toansi(result);
if test <> '' then
result:=test;
end;
У Булгакова есть цикл рассказов "Записки на манжетах".
Мой цикл называется "Записки на туалетной бумаге салфетках".
Итак, "Записки на салфетках. Как я обертывал Synapse".