NetHopper 3.0 provides an entity called the URL Manipulator, which provides web transaction services:
Services for converting string URLs into web transaction requests
And so on....
NetHopper 3.0 provides numerous facilities for processing URLs and transaction requests.
There are three kinds of URL-like entities to deal with here: raw URL strings, wholeURL frames, and transaction request frames. URL strings are simply the standard URL strings a user my type in, or which an HTML document might list in a hyperlink reference. A URL string might be relative to a base URL.
WholeURL frames are a parsed version of the URL string which includes more contect information and is guaranteed to be an absolute URL. In addition, a wholeURL separates the basic URL information from "extra data" (typically form data), for faster processing.
A transaction request frame includes even more context than a wholeURL by precisely defining the protocol "method" to be used, authentication information, caching modes, and user status display flags.
Most of the NetHopper APIs accept transaction request frames; however, the user typically wants to type in URL strings. The URL Manipulator provides all the methods you'll need to bridge between the two worlds.
The URL Manipulator is a ROM portion of the NetHopper Core. You access the URL Manipulator using a Unit interface. Simply include the "URL.unit" file in your project then access the URL manipulator using a unit refernce:
UnitReference( kURLUnitSymbol,kURLInterfaceSubUnitSymbol);
Note: If the NetHopper Core isn't installed, this unit reference will be bogus. You should use the kMissingImportsFunc at runtime to determine whether your package is missing any unit reference imports.
The Transaction Core provides a subunit for manipulating URL strings and wholeURL frames. This subunit can currently be accessed by referencing TransactionManager.fURLManipulator. In the following sections this reference will be referred to as the URLManipulator.
Note: the URL manipulation code is now exported as a unit separate from the Transaction Core.
Typically a URL arrives in the form of a full or relative URL string. These strings need to be parsed into something more useful. This converstion converts a string URL to a wholeURL frame. The Transaction Core provides methods for parsing URL strings into wholeURL frames. The wholeURL frame holds all of the info in a URL string in a useful format.
You can test two whole URLs for equality by calling the method URLEqual. This method takes as parameters the two wholeURLs you wish to test.
You can use the following methods to access specific parts of a whole URL.
Example: in the URL "http://www.allpen.com:80/nethopper-api/URL_unit_info.html#aName" the parts are:
Sometimes you'll want to generate a string representation of a wholeURL. To do this, use the ToString method as follows:
The URL Manipulator provides some additional methods for manipulating Transaction Requests.
In order to use a wholeURL to perform transactions, you need to insert the wholeURL into a transaction request frame.
You can then manipulate and pass off this transaction request frame to a Transaction Manager.
A transaction's "extra data" is typically used for things like posting forms data. You can access the whole URL's extra data by using the method GetExtraData as follows:
You can set the whole URL's extra data by using the method SetExtraData as follows:
URLs themselves are "incomplete" transaction requests. You need to specify additional context to provide a complete transaction request. For instance, HTTP 1.0 has three protocol modes: GET, POST, and HEAD. By default the protocol mode is assumed to be GET, but there is no place to specify the mode in an HTTP URL. A transaction request frame provides this additional context so that you can specify the non-default transaction mode.
Most protocols support more than one transaction mode; however, most URLs do not specify the kind of transaction to execute. For instance, you can both send and receive files using FTP, but by default an FTP URL specifies a receive transaction. Because of this, a transaction request frame provides a context around a URL in which you can specify the transaction mode you wish to carry out.
You can set the protocol mode that NetHopper uses as follows
This example sets the transaction mode to HTTP POST. In the case of HTTP this tells the HTTP protocol to post some data and wait for a response.
You can set whether the Transaction Request should pull data from any local caches. If you set this value to TRUE (the default), local caches are searched for the content first. If you set this value to NIL, the local cache is ignored.
Where lookAtCache is a boolean-- TRUE or NIL.
You can control whether transaction status is displayed to the user by setting a slot in the transaction frame:
URLManipulator:SetStatusDisplayMode(transactionRequest, mode);
Where mode can be one of the following:
The complementary method to SetStatusDisplayMode is GetStatusDisplayMode:
Where displayMode is one of the symbols given above.