help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Types][Procedures and functions][Variables] Reference for unit 'http' (#powtils_main)

HttpGet

Declaration

Source position: http.pas line 45

function HttpGet(

  const url: String

):String;

Notes

Gets content from a url (http fetch, http get). It is the simplest way to grab web page content from an external website.

If the page you request sends you a redirect error code such as 301 or 302, the HttpGet function will automatically try and find the correct page and send the content of the final arrival page after any redirects.

If you want to set the User Agent, use the function HttpGet1.

Error codes

If there was an error found, the function returns the strings:

SSL/HTTPS

At current time of writing the HTTP.PAS unit is not capable of getting SSL/HTTPS web pages. You can try cURL or Synapse if you need that functionality. SSL/HTTPS may be a feature added to the HTTP.PAS unit in the future, however we are wondering if maybe the HTTP.PAS unit is just reinventing cURL since it is very similar (although http.pas is written in Pascal whereas cURL is written in C). You can send us your thoughts on the mailing list about the future of the http.pas unit.

Developer note

As of version 1.6.0.0 this function has not been optimized.. it grabs the page char by char. In the future it will be optimized to be faster using larger socket chunks.

Example

var
  tmp: string;
begin
  webwrite('Someone's web page is below');
  webwrite('<hr>');
  // you should do a <FRAME> here
  tmp:= HttpGet('http://yahoo.com');
  webwrite(tmp);
  // you should do a closing </FRAME> here
  // otherwise strip the <HTML> and <HEAD> from the web page you stole, and integrate 
  // it into your content
end.

Tips

No httpconnect or httpclose is required before making a call to this function. It does that internally for you.





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505