Article View: borland.public.cppbuilder.internet.web
Article #160Re: Indy 9 HTTP Client and Authentication?
From: Remy Lebeau (TeamB)
Date: Thu, 13 Sep 2007 18:37
Date: Thu, 13 Sep 2007 18:37
60 lines
2379 bytes
2379 bytes
"Chris" <chris@privacy.com> wrote in message
news:46e974aa$1@newsgroups.borland.com...
> I already have the usernames and passwords stored and I
> just want to be able to pass them to the server "on-the-fly"
> without even seeing the login dialogue box.
Use the TIdHTTP's Request->Username and Request->Password properties, ie:
{
AnsiString fname = "C:\\JPGTest.jpg";
TFileStream *image = new TFileStream(fname, fmCreate);
try
{
IdHTTP1->Request->Username = "whatever";
IdHTTP1->Request->Password = "whatever";
IdHTTP1->Get("http://192.168.1.101/jpg/1/image.jpg", image);
}
__finally {
delete image;
}
try {
Image1->Picture->LoadFromFile(fname);
}
__finally {
DeleteFile(fname);
}
}
Alternatively:
{
TMemoryStream *image = new TMemory;
try
{
IdHTTP1->Request->Username = "whatever";
IdHTTP1->Request->Password = "whatever";
IdHTTP1->Get("http://192.168.1.101/jpg/1/image.jpg", image);
image->Position = 0;
TJPEGImage *jpg = new TJPEGImage;
try
{
jpg->LoadFromStream(image);
Image1->Picture->Assign(jpg);
}
__finally {
delete jpg;
}
}
__finally {
delete image;
}
}
Gambit
Technical Details
Message-ID:
<46e9849e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46e974aa$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,f4de428f9278b0d3 X-Google-Attributes: gidfeeec,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.web References: <46e974aa$1@newsgroups.borland.com> Subject: Re: Indy 9 HTTP Client and Authentication? Date: Thu, 13 Sep 2007 11:37:31 -0700 Lines: 62 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: 75.83.29.61 Message-ID: <46e9849e$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1189708958 75.83.29.61 (13 Sep 2007 11:42:38 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail