spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column50


Using JavaScript in HomeSite 4.0, Part III

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

The HTTPProvider Object's Methods, Part II

SaveReceivedStreamToFile(fileName, overwriteFlag)String

This method saves the received stream to a file, and overwrites an existing file if overwriteFlag is true. This method returns an error message upon failure. It returns "File already exists" when the given fileName exists and overwriteFlag is false. It returns "Path does not exist" when fileName is not found.

The following script reads an html page from a server and tries to save it to a local disk:

var app = Application;
function Main() {
  var app = Application;
  app.HTTPProvider.URL = "http://www.webreference.com/js/tips/990923.html";
  app.HTTPProvider.Get();
  var errorMsg = app.HTTPProvider.SaveReceivedStreamToFile
   ("d:\\yehuda\\990923.html", false );
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  if (errorMsg != "")
    {
     app.MessageBox("Save failed: " + errorMsg, "Save Error", 0);
    }
  app = null;
}

The first run of this script creates the file on the local disk. The second run will fail to overwrite the existing file because the overwriteFlag is false. This is the window that will pop up:

Post()None

Performs an HTTP POST method request.

Head()None

Performs an HTTP HEAD method request.

GetAsync()None

Performs an HTTP GET method request asynchronously.

PostAsync()None

Performs an HTTP POST method asynchronously.

HeadAsync()None

Performs an HTTP HEAD method request asynchronously.

Abort()None

Aborts the current HTTP operation.

URLEncode(stringValue)String

Converts a string to a URLEncoded format. Usefull when populating URL or FORM data.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Created: October 11, 1999
Revised: October 15, 1999

URL: http://www.webreference.com/js/column50/httpmeth2.html