HANDLE.NET Proxy Server System

1. Resolving Handles Using the Proxy Server System
2. Encoding Handles for Use in URIs
3. Proxy Server Query Parameters
4. Proxy Server REST API

 

CNRI runs a proxy server system at http://hdl.handle.net/. This HANDLE.NET Service is a collection of web servers that understand the handle protocol and know how to talk to the Handle System. Many implementations of the Handle System intended to help manage web content use handles embedded in URLs on web pages, and for the convenience of their customers, use the proxy server for resolution. CNRI's proxy server uses the proxy servlet code that is available for download.

1. Resolving Handles Using the Proxy Server System

For any HTTP request that combines the proxy's domain name with a handle, for example

http://hdl.handle.net/4263537/5555

one of the proxy servers will query the Handle System for the handle, take the URL in the handle record (or if there are multiple URLs in the handle record it will select one, and that selection is in no particular order) and send an HTTP redirect to that URL to the user's web browser. If there is no URL value, the proxy will display the handle record.

In addition to handle values of type URL, the proxy server understands values of handle value type 10320/loc. These values contain XML describing multiple redirection endpoints for the handle and conditions under which the proxy should use them. For further documentation see this overview page and the HANDLE.NET Technical Manual.

The proxy server displays a "Handle Not Found" error page when queried for a handle that it cannot find.

The handles 4263537/5555 and 4263537/5555/ are both valid handles, but it is unusual for a handle to have trailing slash. If a resolution request for a handle with a trailing slash is received by the proxy server and that handle is not found, the proxy server will return an error report that includes a warning that the requested handle contained a trailing slash, and a link to click to resolve the same string without the slash.

To speed resolution, the proxy servers cache handle values, with the TTL typically set to 24 hours. This means that if a handle value is changed, it can take up to 24 hours before the new value is returned.

2. Encoding Handles for Use in URIs

The Handle System uses UTF-8, a Unicode implementation, and has no character set constraints. But the proxy server is a web server that sends redirects to web browsers using HTTP syntax, so characters in handles that may not be interpreted correctly by web browsers, for example '?', should be avoided or encoded. A non-ASCII character in a handle should be converted to UTF-8, and each UTF-8 byte that isn't ASCII should be percent-encoded.

The "#" is another example. Only if you send the proxy server the handle

4263537/5555#resolve

encoded as

http://hdl.handle.net/4263537/5555%23resolve

will the proxy correctly resolve the handle. If it is not encoded, #resolve will be treated as a fragment and removed by the web browser before it gets to the proxy, which will then attempt to resolve 4263537/5555 instead.

The following characters, at least, require percent-encoding:

Character Encoding
% %25
# %23
SPACE %20
? %3F

Note also that web browser treatment of "/./" and "/../" can be inconsistent. It is recommended that one of the slashes be percent encoded, e.g., change "/./" to "/.%2F" and "/../" to "/..%2F".

3. Proxy Server Query Parameters

noredirect
Do not redirect using URL or 10320/loc values; display handle values instead.
ignore_aliases
Ordinarily the proxy will take a handle value of type HS_ALIAS to be a handle that should be resolved instead of the input handle; with this parameter values of type HS_ALIAS are ignored.
auth
Authoritative query. The proxy will bypass its cache and resolve the handle at an authoritative server.
cert
Certified query. The proxy will require an authenticated response from the handle server. Not generally needed by end users.
index
Only resolve the handle value at the specified index. May be repeated to resolve multiple indices.
type
Only resolve handle values of the specified type. May be repeated to resolve multiple types.
urlappend
The value of this parameter is appended to the end of the URL used for redirection.
locatt=key:value
For multiple redirection; specifies a key:value pair to determine the choice of redirection from 10320/loc values.
action=showurls
For multiple redirection; returns an XML representation of the possible redirect locations.
 

4. Proxy Server REST API

The handle proxy REST API allows programmatic access to handle resolution using HTTP.

 

Example Request/Response

A REST API request can be made by performing a standard HTTP GET of

/api/handles/<handle>

The API returns JSON.

For example, http://hdl.handle.net/api/handles/4263537/4000 yields the response

{
   "responseCode":1,
   "handle":"4263537/4000",
   "values":[
      {
         "index":100,
         "type":"HS_ADMIN",
         "data":{
            "format":"admin",
            "value":{
               "handle":"0.NA/4263537",
               "index":200,
               "permissions":"011111111111"
            }
         },
         "ttl":86400,
         "timestamp":"2000-04-10T22:41:46Z"
      },
      {
         "index":1,
         "type":"URL",
         "data":{ "format":"string", "value":"http://www.handle.net/index.html" },
         "ttl":86400,
         "timestamp":"2001-11-21T16:21:35Z"
      },
      {
         "index":2,
         "type":"EMAIL",
         "data":{ "format":"string", "value":"hdladmin@cnri.reston.va.us" },
         "ttl":86400,
         "timestamp":"2000-04-10T22:41:46Z"
      }
   ]
}
 

Response Format

The response is a JSON object which includes a "responseCode" (an integer referring to a Handle protocol response code), an echo of the "handle" resolved, and either a list of "values" or, in the case of an error, an optional "message" which is a string describing the error.

Each value is a JSON object with generally 5 attributes:

  • "index" : an integer
  • "type" : a string
  • "data" : an object, see below
  • "ttl" : the time-to-live in seconds of the value, an integer (or, in the rare case of an absolute expiration time, that expiration time as an ISO8601-formatted string)
  • "timestamp" : an ISO8601-formatted string

Handle value data is an object with properties "format", a string, and "value".

  • If "format"="string", "value" is a string, representing the data as a UTF-8 string.
  • If "format"="base64", "value" is a string, with a BASE64 encoding of the data.
  • If "format"="hex", "value" is a string, with a hex encoding of the data.
  • If "format"="admin", "value" is an object, representing an HS_ADMIN value, with properties "handle" (a string), "index" (an integer), and "permissions" (a string, representing the bitmask of permissions).
  • If "format"="vlist", "value" is an list of objects, representing an HS_VLIST value; each object in the list has properties "handle" (a string) and "index" (an integer).
  • If "format"="site", "value" is an object, representing an HS_SITE value. As the structure of this object is complicated and generally of limited technical interest it is currently omitted from this documentation.
 

Response Codes

  • 1 : Success. (HTTP 200 OK)
  • 2 : Error. Something unexpected went wrong during handle resolution. (HTTP 500 Internal Server Error)
  • 100 : Handle Not Found. (HTTP 404 Not Found)
  • 200 : Values Not Found. The handle exists but has no values (or no values according to the types and indices specified). (HTTP 200 OK)
 

Query Parameters

This proxy server system REST API is CORS-compliant, however, JSONP callbacks are also supported using a "callback" query parameter.

The presence of the "pretty" query parameter instructs the server to pretty-print the JSON output.

The "auth" query parameter instructs the proxy server to bypass its cache and query a primary handle server directly for the newest handle data.

The "cert" query parameter instructs the proxy server to request an authenticated response from the source handle server. Not generally needed by end users.

The "type" and "index" query parameters allow the resolution response to be restricted to specific types and indexes of interest. Multiple "type" and "index" parameters are allowed and values are returned which match any of the specified types or indexes. For example,

For example, http://hdl.handle.net/api/handles/4263537/4000?type=URL&type=EMAIL&callback=processResponse yields the response

processResponse({
   "responseCode":1,
   "handle":"4263537/4000",
   "values":[
      {
         "index":1,
         "type":"URL",
         "data":{ "format":"string", "value":"http://www.handle.net/index.html" },
         "ttl":86400,
         "timestamp":"2001-11-21T16:21:35Z"
      },
      {
         "index":2,
         "type":"EMAIL",
         "data":{ "format":"string", "value":"hdladmin@cnri.reston.va.us" },
         "ttl":86400,
         "timestamp":"2000-04-10T22:41:46Z"
      }
   ]
});

spacer
 

31 July 2014