Тема: idhttpserver
Показать сообщение отдельно
  #24  
Старый 04.09.2012, 18:55
pireved pireved вне форума
Прохожий
 
Регистрация: 20.08.2012
Сообщения: 15
Репутация: 10
По умолчанию

Цитата:
Сообщение от DJ PhoeniX
IdHTTP.Response.БлаБлаБла
Код:
procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  var
  doc:string;
  typ,mime:string;
  body:tstringstream;
begin
 
 body:=tstringstream.Create('');
      try
      myhttp := TIdHTTP.Create(nil);
      myhttp.HandleRedirects := true;
      myhttp.AllowCookies:=true;
      myhttp.CookieManager:=cm;
      doc:='http://'+ARequestInfo.Host+ARequestInfo.Document;
      typ:=get_type(doc);
      mime:=get_mime(typ);
      myhttp.Request.RawHeaders.Text:=ARequestInfo.RawHeaders.Text;
      AResponseInfo.ContentType:=mime;
      AResponseInfo.CustomHeaders:=ARequestInfo.RawHeaders;
      body.WriteString(myhttp.Get(doc));
      AResponseInfo.RawHeaders.Text:=myhttp.Response.RawHeaders.Text;
      AResponseInfo.ResponseText:=myhttp.ResponseText;
     AResponseInfo.ContentText:=body.DataString;
body.Free;
      except
//
      end;
end;
вот что получилось..
напоминает узелковую письменность))
но вариантов перепробовал сотни уже всяких. так работает более менее без ошибок и вылетов.
или это тупик или я вообще не туда пошел
get_mime и get_type функции определяющие mime type по расширению скачиваемого документа, если его нету - значит тип =text/html
Ответить с цитированием