[Pharo-project] Decode url form with Zinc-HTTP
Hi Sven, In WebUtils one can decode an URL this way ( WebUtils decodeUrlEncodedForm: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) keys anyOne resulting in 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]' In Zinc-HTTP I didn't find a method for decoding an encoded HTTP address: ( ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) .... ? but there is #unescapePercents in Network package (by the way if it's the opposite of #encodeForHTTP shouldn't be #decodeFromHTTP ?) 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' unescapePercents 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]' but I want to maximize package dependency and not system dependency. Is there a way to decode url's in Zinc-HTTP without use #unescapePercents ? Cheers, -- Hernán Morales Information Technology Manager, Institute of Veterinary Genetics. National Scientific and Technical Research Council (CONICET). La Plata (1900), Buenos Aires, Argentina. Telephone: +54 (0221) 421-1799. Internal: 422 Fax: 425-7980 or 421-1799.
Hernán,
From the class comment of ZnUrl:
[...] The methods in accessing protocols do not do any encoding, those in printing do. [...] Taking your example: (ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') pathSegments an OrderedCollection('entrez' 'eutils' 'esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]') (ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') path 'entrez/eutils/esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]' (ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') printString 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' If you inspect a ZnUrl instance you will notice that the internal Smalltalk representation is unencoded. But its #printString and the argument to #fromString: are. You could programmatically build up a ZnUrl using accessors and supplying unencoded (path) elements. HTH, Sven On 06 Apr 2011, at 22:38, Hernán Morales Durand wrote:
Hi Sven,
In WebUtils one can decode an URL this way
( WebUtils decodeUrlEncodedForm: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) keys anyOne
resulting in
In Zinc-HTTP I didn't find a method for decoding an encoded HTTP address:
( ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) .... ?
but there is #unescapePercents in Network package (by the way if it's the opposite of #encodeForHTTP shouldn't be #decodeFromHTTP ?)
'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' unescapePercents
but I want to maximize package dependency and not system dependency. Is there a way to decode url's in Zinc-HTTP without use #unescapePercents ?
Cheers,
-- Hernán Morales Information Technology Manager, Institute of Veterinary Genetics. National Scientific and Technical Research Council (CONICET). La Plata (1900), Buenos Aires, Argentina. Telephone: +54 (0221) 421-1799. Internal: 422 Fax: 425-7980 or 421-1799.
Cool. Thanks Sven! 2011/4/7 Sven Van Caekenberghe <sven@beta9.be>:
Hernán,
From the class comment of ZnUrl:
[...]
    The methods in accessing protocols do not do any encoding, those in printing do.
[...]
Taking your example:
 (ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') pathSegments
    an OrderedCollection('entrez' 'eutils' 'esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]')
(ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') path
    'entrez/eutils/esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]'
(ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') printString
    'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...'
If you inspect a ZnUrl instance you will notice that the internal Smalltalk representation is unencoded. But its #printString and the argument to #fromString: are. You could programmatically build up a ZnUrl using accessors and supplying unencoded (path) elements.
HTH,
Sven
On 06 Apr 2011, at 22:38, Hernán Morales Durand wrote:
Hi Sven,
In WebUtils one can decode an URL this way
( WebUtils decodeUrlEncodedForm: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) keys anyOne
resulting in
In Zinc-HTTP I didn't find a method for decoding an encoded HTTP address:
( ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) .... ?
but there is #unescapePercents in Network package (by the way if it's the opposite of #encodeForHTTP shouldn't be #decodeFromHTTP ?)
'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' unescapePercents
but I want to maximize package dependency and not system dependency. Is there a way to decode url's in Zinc-HTTP without use #unescapePercents ?
Cheers,
-- Hernán Morales Information Technology Manager, Institute of Veterinary Genetics. National Scientific and Technical Research Council (CONICET). La Plata (1900), Buenos Aires, Argentina. Telephone: +54 (0221) 421-1799. Internal: 422 Fax: 425-7980 or 421-1799.
One more thing, I've tried to install in the new released Pharo with CogVM: Gofer new squeaksource: 'ZincHTTPComponents'; package: 'ConfigurationOfZincHTTPComponents'; load. (Smalltalk at: #ConfigurationOfZincHTTPComponents) perform: #load and loading manually the latest Zinc-HTTP from the Monticello Browser. either way I get errors (attached debugger output from the ConfigurationOf script). What is the proper way to install or update to the latest version, Cheers, 2011/4/7 Hernán Morales Durand <hernan.morales@gmail.com>:
Cool. Thanks Sven!
2011/4/7 Sven Van Caekenberghe <sven@beta9.be>:
Hernán,
From the class comment of ZnUrl:
[...]
    The methods in accessing protocols do not do any encoding, those in printing do.
[...]
Taking your example:
 (ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') pathSegments
    an OrderedCollection('entrez' 'eutils' 'esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]')
(ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') path
    'entrez/eutils/esearch.fcgi?db=nuccore&term=science[journal]+AND+breast+cancer+AND+2009[pdat]'
(ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...') printString
    'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...'
If you inspect a ZnUrl instance you will notice that the internal Smalltalk representation is unencoded. But its #printString and the argument to #fromString: are. You could programmatically build up a ZnUrl using accessors and supplying unencoded (path) elements.
HTH,
Sven
On 06 Apr 2011, at 22:38, Hernán Morales Durand wrote:
Hi Sven,
In WebUtils one can decode an URL this way
( WebUtils decodeUrlEncodedForm: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) keys anyOne
resulting in
In Zinc-HTTP I didn't find a method for decoding an encoded HTTP address:
( ZnUrl fromString: 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' ) .... ?
but there is #unescapePercents in Network package (by the way if it's the opposite of #encodeForHTTP shouldn't be #decodeFromHTTP ?)
'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26t...' unescapePercents
but I want to maximize package dependency and not system dependency. Is there a way to decode url's in Zinc-HTTP without use #unescapePercents ?
Cheers,
-- Hernán Morales Information Technology Manager, Institute of Veterinary Genetics. National Scientific and Technical Research Council (CONICET). La Plata (1900), Buenos Aires, Argentina. Telephone: +54 (0221) 421-1799. Internal: 422 Fax: 425-7980 or 421-1799.
On 07 Apr 2011, at 17:37, Hernán Morales Durand wrote:
One more thing, I've tried to install in the new released Pharo with CogVM:
Gofer new squeaksource: 'ZincHTTPComponents'; package: 'ConfigurationOfZincHTTPComponents'; load. (Smalltalk at: #ConfigurationOfZincHTTPComponents) perform: #load
and loading manually the latest Zinc-HTTP from the Monticello Browser.
either way I get errors (attached debugger output from the ConfigurationOf script). What is the proper way to install or update to the latest version,
As described here: http://homepage.mac.com/svc/Zinc-HTTP-Components/ Gofer it squeaksource: 'ZincHTTPComponents'; package: 'Zinc-HTTP'; package: 'Zinc-Tests'; load should always work and load the latest version. The class comment of ConfigurationOfZincHTTPComponents says ConfigurationOfZincHTTPComponents project latestVersion load. I am no expert, so I'll try to rember to ask this at the next Pharo sprint. Sven
participants (2)
-
Hernán Morales Durand -
Sven Van Caekenberghe