On Dec 14, 2011, at 2:00 PM, Sven Van Caekenberghe wrote:
On 13 Dec 2011, at 22:42, Stéphane Ducasse wrote:
Excellent now can you open an issue and provide add these examples in the ZnUrl class comment?
You are a slave driver ;-)
Yes I like that. whipping the crack :) Stef
==================== Summary ====================
Name: Zinc-HTTP-SvenVanCaekenberghe.229 Author: SvenVanCaekenberghe Time: 14 December 2011, 1:45:28 pm UUID: b239edd4-c432-4139-a71a-d27618beef91 Ancestors: Zinc-HTTP-SvenVanCaekenberghe.228
expanded the ZnUrl class comment
=================================================
Now it reads like this:
I am ZnUrl, an implementation of an interpreted HTTP(S) URL/URI. Contrary to other implementations, this one is specific for HTTP(S).
I consist of the following parts: - scheme - either #http, #https or nil - host - hostname string or nil - port - port integer or nil - segments - collection of path segments, ends with #/ for directories - query - query dictionary or nil - fragment - fragment string or nil
The syntax of my external representation informally looks like this
scheme://host:port/segments?query#fragment
I am most often created by parsing my external representation using either my #fromString: class method or by sending the #asZnUrl convenience method to a String. Using #asZnUrl helps in accepting both Strings and ZnUrls arguments.
ZnUrl fromString: ''http://www.google.com/search?q=Smalltalk''.
I can also be constucted programmatically.
ZnUrl new scheme: #https; host: ''encrypted.google.com''; addPathSegment: ''search''; queryAt: ''q'' put: ''Smalltalk''; yourself.
My components can be manipulated destructively. Here is an example:
(''http://www.google.com/?one=1&two=2'' asZnUrl) queryAt: ''three'' put: ''3''; queryRemoveKey: ''one''; yourself.
Some characters of parts of a URL are illegal because they would interfere with the syntax and further processing and thus have to be encoded. The methods in accessing protocols do not do any encoding, those in parsing and printing do. Here is an example:
(''http://www.google.com'' asZnUrl) addPathSegment: ''some encoding here''; queryAt: ''and some encoding'' put: ''here, too''; yourself
My parser is somewhat forgiving and accepts some unencoded URLs as well, like most browsers would.
''http://www.example.com:8888/a path?q=a, b, c'' asZnUrl.
I can parse in the context of a default scheme, like a browser would do.
ZnUrl fromString: ''www.example.com'' defaultScheme: #http
Given a scheme, I know its default port, try #portOrDefault.
A path defaults to what is commonly referred to as slash, test with #isSlash. Paths are most often (but don''t have to be) interpreted as filesystem paths. To support this, I have #isFile and #isDirectory tests and #file and #directory accessors.
I have some support to handle one URL in the context of another one, this is also known as a relative URL in the context of an absolute URL. Refer to #isAbsolute, #isRelative and #inContextOf:
''/folder/file.txt'' asZnUrl inContextOf: (''http://fileserver.example.net:4400'' asZnUrl).
Sometimes, the combination of my host and port are referred to as authority, see #authority.
URL/URI/URN (Uniform/Universal Resource Locator/Identifier/Name) are closely related and can be and are used as synonyms is many contexts. Refer to http://en.wikipedia.org/wiki/Url for more information.
Part of Zinc HTTP Components.