<doc>
  <legacy_id>2482</legacy_id>
  <name>URLStatus</name>
  <type>function</type>
  <syntax>
    <example>the URLStatus of <i>url</i></example>
    <example>URLStatus(<i>url</i>)</example>
  </syntax>
  <library>Internet library</library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>Networks &amp; Communication</category>
    <category>Standalone Applications</category>
  </classification>
  <references>
    <command tag="post">post Command</command>
    <command tag="libURLDownloadToFile">libURLDownloadToFile Command</command>
    <command tag="libURLftpUpload">libURLftpUpload Command</command>
    <function tag="libURLLastRHHeaders">libURLLastRHHeaders Function</function>
    <function tag="libURLErrorData">libURLErrorData Function</function>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
    <changed version="1.1.1"></changed>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
  </classes>
  <security>
    <network/>
  </security>
  <summary><glossary tag="return">Returns</glossary> the status of <glossary tag="upload">uploads</glossary> and <glossary tag="download">downloads</glossary> that were started with the <command tag="load">load</command>, <command tag="libURLDownloadToFile">libURLDownloadToFile</command>, <command tag="libURLftpUpload">libURLftpUpload</command>, and <command tag="libURLftpUploadFile">libURLftpUploadFile</command> <glossary tag="command">commands</glossary>.</summary>
  <examples>
    <example>the URLStatus of "http://www.example.com/test.html"</example>
    <example>wait until URLStatus(field "URL") is "cached"</example>
    <example>if URLStatus(myFile) is "error" then get libURLErrorData(myFile)</example>
  </examples>
  <description>
    <p>Use the <b>URLStatus</b> <control_st tag="function">function</control_st> to check the progress of an <glossary tag="upload">upload</glossary> or <glossary tag="download">download</glossary>.</p><p/><p><b>Parameters:</b></p><p>The <i>url</i> is a <keyword tag="URL">URL</keyword>, or an <glossary tag="expression">expression</glossary> that <glossary tag="evaluate">evaluates</glossary> to a <keyword tag="URL">URL</keyword>.</p><p/><p><b>Value:</b></p><p>The <b>URLStatus</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> one of the following values:</p><p/><p>"queued": on hold until a previous request to the same site is completed</p><p>"contacted": the site has been contacted but no data has been sent or received yet</p><p>"requested": the URL has been requested</p><p>"loading,<i>bytesReceived</i>,<i>bytesTotal</i>": the <keyword tag="URL">URL</keyword> data is being received</p><p>"uploading,<i>bytesReceived</i>,<i>bytesTotal</i>": the file is being <glossary tag="upload">uploaded</glossary> to the URL</p><p>"cached": the URL is in the <glossary tag="cache">cache</glossary> and the <glossary tag="download">download</glossary> is complete</p><p>"uploaded": the application has finished uploading the file to the URL</p><p>"error": an error occurred and the URL was not transferred</p><p>"timeout": the application timed out when attempting to transfer the URL</p><p>empty: the URL was not loaded, or has been unloaded</p><p/><p><b>Comments:</b></p><p>You can check the <b>cachedURLs</b> <control_st tag="function">function</control_st> to determine whether a <keyword tag="URL">URL</keyword> has already been <glossary tag="download">downloaded</glossary>. The <keyword tag="URL">URL</keyword> is not placed in the <function tag="cachedURLs">cachedURLs</function> until the <glossary tag="download">download</glossary> is complete, however, so you must use the <b>URLStatus</b> <control_st tag="function">function</control_st> to check a pending <glossary tag="download">download</glossary> or one that has been started but not finished.</p><p/><p><code/><img src="202651"/> <b>Tip:</b><code/> To update a progress indicator or perform other tasks during uploads and downloads, use the <command tag="libURLSetStatusCallback">libURLSetStatusCallback</command> <glossary tag="command">command</glossary> to automatically send a <glossary tag="callback">callback message</glossary> every time the <function tag="URLStatus">URLStatus</function> <control_st tag="function">function</control_st> is updated. You can then write a <glossary tag="handler">handler</glossary> for this <keyword tag="message box">message</keyword> that performs whatever tasks are needed.</p><p/><p>The third item (<i>bytesTotal</i>) in the "loading" or "uploading" status report is empty if it is not possible to determine the total file size. (For example, if an <keyword tag="ftp">FTP</keyword> <glossary tag="server">server</glossary> does not support the SIZE command, it's not possible to determine the file size when <glossary tag="download">downloading</glossary> a file from that <glossary tag="server">server</glossary>.)</p><p/><p>If an error occurs during downloading, the <b>URLStatus</b> <control_st tag="function">function</control_st> returns "error". You can get the error message using the <function tag="libURLErrorData">libURLErrorData</function> <control_st tag="function">function</control_st>.</p><p/><p><code/><img src="202653"/> <b>Important!</b><code/> The <b>URLStatus</b> <control_st tag="function">function</control_st> is part of the <glossary tag="Internet library">Internet library</glossary>. To ensure that the <control_st tag="function">function</control_st> works in a <glossary tag="standalone application">standalone application</glossary>, you must include this <glossary tag="LiveCode custom library">custom library</glossary> when you create your <glossary tag="standalone application">standalone</glossary>. In the Inclusions section of the <glossary tag="Standalone Application Settings">Standalone Application Settings</glossary> window, make sure "Internet Library" is selected in the list of script libraries.</p><p/><p><b>Changes:</b></p><p>The <b>URLStatus</b> <control_st tag="function">function</control_st> became part of the <glossary tag="Internet library">Internet library</glossary> in version 1.1. In previous versions, it was not a library <control_st tag="function">function</control_st>.</p><p/><p>The<code> queued</code>,<code> uploading</code>, and<code> uploaded </code>values were introduced in version 1.1.1. In previous versions, file transfers to the same host were not queued, and the <b>URLStatus</b> function could not be used to check the progress of <glossary tag="upload">uploads</glossary>.</p>
  </description>
</doc>