Decode url form with Zinc-HTTP

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Decode url form with Zinc-HTTP

hernanmd
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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
) 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
) .... ?

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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
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.

Reply | Threaded
Open this post in threaded view
|

Re: Decode url form with Zinc-HTTP

Sven Van Caekenberghe
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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') printString

        'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'

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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
> ) 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
> ) .... ?
>
> 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
> 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.
>


Reply | Threaded
Open this post in threaded view
|

Re: Decode url form with Zinc-HTTP

hernanmd
Cool. Thanks Sven!

2011/4/7 Sven Van Caekenberghe <[hidden email]>:

> 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') printString
>
>        'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>
> 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>> ) 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>> ) .... ?
>>
>> 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>> 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.
>

Reply | Threaded
Open this post in threaded view
|

Re: Decode url form with Zinc-HTTP

hernanmd
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 <[hidden email]>:

> Cool. Thanks Sven!
>
> 2011/4/7 Sven Van Caekenberghe <[hidden email]>:
>> 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D') printString
>>
>>        'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi%3Fdb%3Dnuccore%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>>
>> 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>>> ) 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>>> ) .... ?
>>>
>>> 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%26term%3Dscience%5Bjournal%5D%2BAND%2Bbreast%2Bcancer%2BAND%2B2009%5Bpdat%5D'
>>> 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.
>>

updateZnHTTP.txt (42K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Decode url form with Zinc-HTTP

Sven Van Caekenberghe

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