Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Proxy probleme (https://www.delphipraxis.net/101350-proxy-probleme.html)

delphinia 11. Okt 2007 18:50


Proxy probleme
 
Liste der Anhänge anzeigen (Anzahl: 1)
Nutzte idHTTPServer und idHTTP als Proxy-Lösung.
Habe hier ne menge beispiele für sowas gefunden.

derzeiiger Code:

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
  IdTCPServer, IdCustomHTTPServer, IdHTTPServer, IdTCPConnection,
  IdTCPClient, IdHTTP, StdCtrls;

type
  TForm1 = class(TForm)
    IdHTTPServer1: TIdHTTPServer;
    IdAntiFreeze1: TIdAntiFreeze;
    Label1: TLabel;
    ListBox1: TListBox;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure IdHTTPServer1CreatePostStream(ASender: TIdPeerThread;
      var VPostStream: TStream);
    procedure IdHTTPServer1CommandGet(AThread: TIdPeerThread;
      ARequestInfo: TIdHTTPRequestInfo;
      AResponseInfo: TIdHTTPResponseInfo);
  private
    { Private-Deklarationen }

  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.IdHTTPServer1CreatePostStream(ASender: TIdPeerThread; var VPostStream: TStream);
begin
        // creating our own stream so that TIdHTTPServer does not automatically
        // free the PostStream before the OnCommandGet event is triggered
  VPostStream := TMemoryStream.Create;
end;

procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
  LHTTP: TIdHTTP;
  LURL: string;
  LMethod: TIdHTTPMethod;
  LSource, LDest: TStream;
begin
  LURL := 'http://' + ARequestInfo.Host;


  Label1.Caption := LURL;
  Label2.Caption := LURL + '?' + ARequestInfo.QueryParams;
  Label3.Caption := ARequestInfo.Command;


  begin

    LSource := nil;
    LDest := nil;

    if ARequestInfo.Command = 'GET' then
    begin
      LMethod := hmGet;
    end
    else
      if ARequestInfo.Command = 'POST' then
      begin
        LMethod := hmPost;
      end
      else
        if ARequestInfo.Command = 'HEAD' then
        begin
          LMethod := hmHead;
        end
        else
        begin
          AResponseInfo.ResponseNo := 501; // not implemented
          Exit;
        end;

    if LMethod <> hmHead then
    begin
      AResponseInfo.ContentStream := TMemoryStream.Create;
      if LMethod = hmPost then
        LSource := ARequestInfo.PostStream;
      LDest := AResponseInfo.ContentStream;
    end;


    if Length(ARequestInfo.QueryParams) > 0 then
    begin
      LURL := LURL + '?' + ARequestInfo.QueryParams;
    end;

    LHTTP := TIdHTTP.Create(nil);
    try
      try
        LHTTP.DoRequest(LMethod, LURL, LSource, LDest);
      finally
        AResponseInfo.ResponseNo := LHTTP.Response.ResponseCode;
        AResponseInfo.ResponseText := LHTTP.Response.ResponseText;
        AResponseInfo.RawHeaders.Assign(LHTTP.Response.RawHeaders);
                // copy over anything else that is needed...
        LHTTP.Free;
      end;
    except
    end;
  end;
end;

end.


Leider werden wie auf dem Bild zu sehen alle möglichen wichtigen dinge nicht durch den Proxy übernommen oder weitergegeben
zb. Bilder, CSS, Cookies etc....

Wo liegt der Fehler??!

delphinia 12. Okt 2007 20:01

Re: Proxy probleme
 
Keine eine Lösung?! hmmm

SirTwist 12. Okt 2007 23:30

Re: Proxy probleme
 
Wenn Du so eine kaputte Webseite bekommst, dann wähl doch mal im Webbrowser "Seiteninformationen" an. Da siehst Du die URLs der in der Webseite enthaltenen Objekte: Bilder, Style sheets, ...

Davon nimmst Du dir mal eine URL und gibst sie direkt im Browser ein. Dann solltest Du ja sehen, ob Dein Proxy das hinbekommt oder nicht. Dann können wir mal weitersehen...

Kleine Frage: ist das als Programmierprojekt gedacht oder benötigst du wirklich einen Proxy?

Gruß, SirTwist

delphinia 13. Okt 2007 03:24

Re: Proxy probleme
 
Ok das Problem habe ich gelöst!


Nun habe ich eigentlich nur noch 2 Problem die Cookies.

1) Wenn ich mit meinem Proxy webseiten besuche wo ich eigentlich eingeloggt bion - so it das mit meinem Proxy nicht so

2) Formulare werden nciht ausgeführt - beispiel suche - gebe nen suchwort ein udn drücke auf suchen . und komme wieder auf die suchseite

lowF 4. Mär 2009 20:57

Re: Proxy probleme
 
Hat das hier irgentwer weiterentwickelt?


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:36 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz