?
Solved

HTTP Get Problem

Posted on 2004-09-04
4
Medium Priority
?
696 Views
Last Modified: 2012-05-05
Dear Sir

I di small application to read the source from a web page

the code:

procedure TForm1.Timer1Timer(Sender: TObject);
var
  ii, jj:integer;
  s1, res :STRING;
begin
timer1.Enabled:= false;

         s1:= idhttp1.Get('http://www.omarfayyad.com/md/index.php');

         ii := pos('startofm',s1)+10;
         jj := pos('endofm',s1)-27;
         res := Copy(s1,ii, jj-ii);
         if (AnsiCompareText(oldres, res)<>0) then
           begin
             oldres:= res;
             memo.Clear;
             memo.Lines[0]:= res;
           end;
idhttp1.Disconnect;
timer1.Enabled:= true;
end;

it isworking fine, put after updating the web page, it reads the new contents.  the second try it reads the old ones. then it reds the new contents the some very old one ....... after 5 .. 7 tryes it starts working will and forgots any old contents.

so please advice where is the problem and from where it gets the old contents when the are changed.

thank you in advance

Eng. Omar Fayyad

0
Comment
Question by:omarmf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Expert Comment

by:MrT-RSI
ID: 11981263
Are you using a proxy server ? Maybe the proxy is delevering you the old version.

Turn the use of a proxy of, or check your IE settings, or try a little 'tweak' by requesting your page with 'a' param, e.g.: .Get('.../index.php?param=123'); maybe this will force the proxy to reload the page.
0
 
LVL 1

Expert Comment

by:mgazza
ID: 12092778
y are you using a conponent? is it worth that overhead?

var
zero:cardinal=0;
procedure HTTPs(URL,Headers:PChar;var OutHeaders, OutDoc:string);

var
  RequestHandle,IOpenHandle : PHandle;
  DataWritten:cardinal;
  buffer:array[0..100] of char;
begin

  IOpenHandle:= InternetOpen('Mozilla/4.0 (compatible)', INTERNET_OPEN_TYPE_PRECONFIG , NIL, NIL, 0);

  // open the file
  RequestHandle:=InternetOpenUrl(iOpenHandle, URL, Headers, length(Headers),
                          INTERNET_FLAG_RAW_DATA or INTERNET_FLAG_SECURE,0);

  if RequestHandle<>nil then begin
   repeat
     if InternetReadFile(RequestHandle,@buffer[0],sizeof(buffer),DataWritten) then
        OutDoc:=OutDoc+copy(buffer,0,DataWritten) else break;
   until DataWritten=0;
   setlength(outheaders,512);
   repeat
    DataWritten:=length(outheaders);
     if HttpQueryInfoA(RequestHandle, HTTP_QUERY_RAW_HEADERS_CRLF, @outheaders[1],DataWritten,zero) then begin
      setlength(outheaders,datawritten);
      break;
     end
     else setlength(outheaders,datawritten*2);
    until datawritten=1024*5;

  end;

  InternetCloseHandle(requestHandle);
  InternetCloseHandle(IOpenHandle);
end;


procedure HTTP(URL,Headers:PChar;var OutHeaders, OutDoc:string);

var
  RequestHandle,IOpenHandle : PHandle;
  DataWritten:cardinal;
  buffer:array[0..100] of char;
begin

  IOpenHandle:= InternetOpen('Mozilla/4.0 (compatible)', INTERNET_OPEN_TYPE_PRECONFIG , NIL, NIL, 0);

  // open the file
  RequestHandle:=InternetOpenUrl(iOpenHandle, URL, Headers, length(Headers),
                          INTERNET_FLAG_RAW_DATA,0);

  if RequestHandle<>nil then begin
   repeat
     if InternetReadFile(RequestHandle,@buffer[0],sizeof(buffer),DataWritten) then
        OutDoc:=OutDoc+copy(buffer,0,DataWritten) else break;
   until DataWritten=0;
   setlength(outheaders,512);
   repeat
    DataWritten:=length(outheaders);
     if HttpQueryInfoA(RequestHandle, HTTP_QUERY_RAW_HEADERS_CRLF, @outheaders[1],DataWritten,zero) then begin
      setlength(outheaders,datawritten);
      break;
     end
     else setlength(outheaders,datawritten*2);
    until datawritten=1024*5;

  end;

  InternetCloseHandle(requestHandle);
  InternetCloseHandle(IOpenHandle);
end;
0
 
LVL 1

Expert Comment

by:mgazza
ID: 12092789
where headers is optional headers #13#10
procedure TForm1.Button1Click(Sender: TObject);
var
Head:Pchar;
d,h:string;
begin

https('https://www.omarfayyad.com/md/index.php',nil,h,d);
or
http('http://www.omarfayyad.com/md/index.php',nil,h,d);
respectfuly
showmessage(h+d)

end;

regards
0
 
LVL 1

Accepted Solution

by:
mgazza earned 1000 total points
ID: 12123431
any comment would be useful
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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