首页 > Uncategorized > URI, URL and URN

URI, URL and URN

  • 本文链接地址:http://zhubaining.com/blog/2009/01/02/archives/uri-url-and-urn
  • 作者:zhubaining

In computing, a Uniform Resource Identifier (URI) is a compact string of characters used to identify or name a resource on the Internet.

A URI may be classified as a locator (URL) or a name (URN), or both.
A Uniform Resource Name (URN) is like a person’s name, while a Uniform Resource Locator (URL) is like his or her street address. The URN defines an item’s identity, while the URL provides a method for finding it.

A typical URN is the ISBN system for uniquely identifying books. ISBN 0486275574 (urn:isbn:0-486-27557-4) cites unambiguously a specific edition of Shakespeare’s play "Romeo and Juliet". In order to gain access to this object and read the book, one would need its location: a URL address. A typical URL for this book is a file path, like file:///C:/MyDocuments/RomeoAndJuliet.pdf, identifying the electronic book saved in a local Windows PC hard disk. So the purposes of URNs and URLs are complementary.

A URN can be used to talk about a resource without implying its location or how to access it.

The HTTP specification uses the more general concept of URIs as its resource identifiers; in practice, however, HTTP applications deal only with the URL subset of URIs.

Some common HTTP methods

HTTP method

Description

GET

Send named resource from the server to the client.

PUT

Store data from client into a named server resource.

DELETE

Delete the named resource from a server.

POST

Send client data into a server gateway application.

HEAD

Send just the HTTP headers from the response for the named resource.

Status Code:

The textual phrase is included only for descriptive purposes; the numeric code is used for all processing.

The following status codes and reason phrases are treated identically by HTTP software:

200 OK
200 Document attached
200 Success
200 All's cool, dude


General URL components(and URL encoding applied on not only http but also mailto, ftp and so on):

<scheme>://<user>:<password>@<host>:<port>/<path>;<params>?<query>#<frag>

Params: the path component for HTTP URLs can be broken into path segments. Each segment can have its own params. For example:

http://www.joes-hardware.com/hammers;sale=false/index.html;graphics=true

query: There is no requirement for the format of the query component. By convention, many gateways expect the query string to be formatted as a series of "name=value" pairs, separated by "&" characters.

Frag: A name for a piece or part of the resource. The frag field is not passed to the server when referencing the object; it is used internally by the client. It is separated from the rest of the URL by the "#" character.

URLs are a powerful tool. Their design allows them to name all existing objects and easily encompass new formats. They provide a uniform naming mechanism that can be shared between Internet protocols.

分类: Uncategorized 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.