Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Working with Internet behind proxy

Posted on 2003-12-02
9
Medium Priority
?
290 Views
Last Modified: 2010-04-05
hi all,

i am writing a program to retrieve contents of web page, but
fail when i read() the URL(http://www.yahoo.com)
the developemnt environment is behind proxy server. anything wrong?

#########################################

procedure TWeb.GrabHtml;
var
  Http1: TIdHttp;
  strUrl: String;
begin
  strUrl := 'http://www.yahoo.com';
  Status := 'Sending query: ' + StrUrl;
  Synchronize (ShowStatus);
  Http1 := TIdHttp.Create(nil);
  try
    Http1.Request.UserAgent := 'User-Agent: NULL';
    Http1.OnWork := HttpWork;
    strRead := Http1.Get(strUrl);
  finally
    Http1.Free;
  end;
end;

#########################################
0
Comment
Question by:lamtl354
  • 4
  • 2
  • 2
9 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 200 total points
ID: 9865166
Hi,

You have to set ProxyParams property of your Http1 (ProxyServer and ProxyPort at least and others if your proxy requires authentication).

Regards, Geo
0
 

Author Comment

by:lamtl354
ID: 9871209
hi geobul,

could you tell me how to set these setting?
thx
0
 
LVL 17

Expert Comment

by:geobul
ID: 9874764
Hi,

This way:

...
  Http1 := TIdHttp.Create(nil);
  try
// new code
   with Http1.ProxyParams do begin
    // at least
    ProxyServer := '127.0.0.1'; // the ip address of your proxy - string
    ProxyPort := 80; // your proxy port - integer
    // if your proxy requires authentication
    ProxyUsername := 'user';
    ProxyPassword := 'password';
    // and perhaps
    BasicAuthentication := true;
  end;
// your code continues
  Http1.Request.UserAgent := 'User-Agent: NULL';
  ...

Regards, Geo
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:lamtl354
ID: 9879583
if i didn't know the proxy setting, how could we do this?
can the applicartion detect proxy setting from somewhere just like what IE do?
0
 
LVL 17

Expert Comment

by:geobul
ID: 9881054
It would be a lot easier if you use the following. You don't have to bother yourself whether there is a proxy or not. If IE works on a computer then this code will work also.

uses URLMon;

procedure TWeb.GrabHtml;
var
  strUrl: String;
  LocalFile: string;
begin
  strUrl := 'http://www.yahoo.com';
  LocalFile := 'c:\yahoo.html';

  if URLDownloadToFile(nil, PChar(strUrl), PChar(LocalFile), 0, nil) <> 0 then
    MessageBox(0, 'Cannot download the file.', PChar(Application.Title), MB_ICONERROR or MB_OK);
end;

Regards, Geo
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 12382303
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
PAQ - Refund

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Karamja (Alan)
EE Cleanup Volunteer
0
 
LVL 17

Expert Comment

by:geobul
ID: 12382947
Why? I think I've answered the question: how to set up proxy settings using Indy's TIdHTTP component. There was a follow-up question also answered by me. What else should I have done?
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 12383023
Ooppps, My bad, Didnt see that post.

I will leave the following recommendation for this question in the Cleanup topic area:
Accept: geobul
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question