Re: Zinc URL and ASCII Encoding

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

Re: Zinc URL and ASCII Encoding

Sven Van Caekenberghe-2
Hi Gareth,

On 19 Mar 2018, at 15:23, Gareth Cox <[hidden email]> wrote:

Hi Sven

Is Zinc being overly fussy with encoding or is ASCII only URL strings a standard.
the following fails in a workspace/playground.

'http://www.yr.no/place/Mexico/Nuevo_León/Monterrey/forecast.xml' asZnUrl

The url comes from the yr.no database (via api). It is vaild if you paste into a browser.
Let me know what you think

Thanks
Gareth

(I am replying with CC to the ML for future reference).

When ZnUrl parses a string representation of a URL it is indeed strict. As per the spec this must be ASCII.

Browsers typically allow a wider range of input.

But of course, these URLs are supported, you just have to construct them differently. If you use the direct construction API, you can use full Unicode.

ZnUrl new 
  scheme: #http; 
  host: 'www.yr.no'; 
  addPathSegments: #('place' 'Mexico' 'Nuevo_León' 'Monterrey' 'forecast.xml');
  yourself.

You'll see that the external representation of your URL is actually the following, which is acceptable to the parser.


BTW, I would do your request as follows (using XML Support) :

ZnClient new
  systemPolicy;
  http;
  host: 'www.yr.no'; 
  addPath: #('place' 'Mexico' 'Nuevo_León' 'Monterrey' 'forecast.xml');
  accept: 'text/xml' asMIMEType;
  contentReader: [ :entity | XMLDOMParser parse: entity contents ];
  get.

In my Pharo 7 image, this gives me a nice coloured, fully parsed DOM:


HTH,

Sven
 

Reply | Threaded
Open this post in threaded view
|

Re: Zinc URL and ASCII Encoding

riverdusty
Thanks Sven

I will have to first deconstruct the url and then reconstruct it as you mentioned.
We discussed this in the discord channel and came to the same conclusion.

I really like your final solution and will probably go with that.

Thanks
Gareth
IT Manager/Developer
email: [hidden email]
cell: +27 (0)78 374 9035
Inspired Org (PTY) Ltd
On 19 Mar 2018 16:55, Sven Van Caekenberghe wrote:
Hi Gareth,

On 19 Mar 2018, at 15:23, Gareth Cox <[hidden email]> wrote:

Hi Sven

Is Zinc being overly fussy with encoding or is ASCII only URL strings a standard.
the following fails in a workspace/playground.

'http://www.yr.no/place/Mexico/Nuevo_León/Monterrey/forecast.xml' asZnUrl

The url comes from the yr.no database (via api). It is vaild if you paste into a browser.
Let me know what you think

Thanks
Gareth

(I am replying with CC to the ML for future reference).

When ZnUrl parses a string representation of a URL it is indeed strict. As per the spec this must be ASCII.

Browsers typically allow a wider range of input.

But of course, these URLs are supported, you just have to construct them differently. If you use the direct construction API, you can use full Unicode.

ZnUrl new 
  scheme: #http; 
  host: 'www.yr.no'; 
  addPathSegments: #('place' 'Mexico' 'Nuevo_León' 'Monterrey' 'forecast.xml');
  yourself.

You'll see that the external representation of your URL is actually the following, which is acceptable to the parser.


BTW, I would do your request as follows (using XML Support) :

ZnClient new
  systemPolicy;
  http;
  host: 'www.yr.no'; 
  addPath: #('place' 'Mexico' 'Nuevo_León' 'Monterrey' 'forecast.xml');
  accept: 'text/xml' asMIMEType;
  contentReader: [ :entity | XMLDOMParser parse: entity contents ];
  get.

In my Pharo 7 image, this gives me a nice coloured, fully parsed DOM:


HTH,

Sven