🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #5147

Re: Indy TCPServer and proxies

#5147
From: Remy Lebeau (TeamB)
Date: Sat, 09 Oct 2004 20:27
59 lines
2948 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message
news:41682b12$1@newsgroups.borland.com...

> I already tried to use it, but how can I set its
> MappedHost and MappedPort when the
> browser send a request?

Use the OnConnect event for that, ie (untested):

    void __fastcall TForm1::IdMappedPortTCP1Connect(TIdMappedPortThread
*AThread)
    {
        // read requested address from the browser...
        AnsiString Request = AThread->Connection->ReadLn(LF,
IdTimeoutDefault, -1);

        AnsiString Command = Fetch(Request, ' ', true, false);
        AnsiString URL = Fetch(Request, ' ', true, false);
        AnsiString Version = Request;

        TIdURI *uri = new TIdURI(URL);
        try
        {
            // update the outbound client accordingly...
            TIdTCPClient *client =
static_cast<TIdTCPClient*>(AThread->OutboundClient);
            client->Host = uri->Host;
            client->Port = uri->Port.ToIntDef(80);

            AThread->NetData = (Command + " " + URL.SubString(8, MaxInt) + "
" + Version);
        }
        __finally {
            delete uri;
        }
    }

    void __fastcall
TForm1::IdMappedPortTCP1OutboundConnect(TIdMappedPortThread *AThread,
Exception *AException)
    {
        if( AException == NULL )
        {
            if( AThread->NetData.Length() )
                AThread->OutboundClient->WriteLn(AThread->NetData);
        }
        else
        {
            AThread->Connection->WriteLn("500 " + AException->Message);
        }
    }

Also, for what it is worth, the current development snapshot of Indy 9 has a
TIdHTTPProxyServer unit available that you might consider looking at as
well.  It is not installed by default.


Gambit
Technical Details
Message-ID: <416849a8$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4166efc5$1@newsgroups.borland.com> <4166fc3a$1@newsgroups.borland.com> <41671c26@newsgroups.borland.com> <4167289e$1@newsgroups.borland.com> <416732b1$1@newsgroups.borland.com> <41673f29$1@newsgroups.borland.com> <4168173c$1@newsgroups.borland.com> <416824b3$1@newsgroups.borland.com> <41682b12$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3acb790ca748eb20
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <4166efc5$1@newsgroups.borland.com> <4166fc3a$1@newsgroups.borland.com> <41671c26@newsgroups.borland.com> <4167289e$1@newsgroups.borland.com> <416732b1$1@newsgroups.borland.com> <41673f29$1@newsgroups.borland.com> <4168173c$1@newsgroups.borland.com> <416824b3$1@newsgroups.borland.com> <41682b12$1@newsgroups.borland.com>
Subject: Re: Indy TCPServer and proxies
Date: Sat, 9 Oct 2004 13:27:27 -0700
Lines: 61
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <416849a8$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1097353640 68.69.17.41 (9 Oct 2004 13:27:20 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail