Re: [Chicken-users] bug update-uri in uri-common

2014-06-16 Thread Kristian Lein-Mathisen
Thank you Peter!

With some manual testing, it's working like expected here.

K.


On Sat, Jun 14, 2014 at 3:11 PM, Peter Bex peter@xs4all.nl wrote:

 On Sat, Jun 07, 2014 at 02:19:22PM +0200, Peter Bex wrote:
  So here's a new poll:
 
  a) The current behaviour of resetting port to #f if it's the default port
   for this scheme is ok.
  b) The port should not be reset, and the uri should be printed with an
  explicit port, even if it's the default for this scheme.
  c) The port should not be reset, but the uri should be printed without
  port if it's the default for this scheme.

 I have now implemented c), and tagged release 1.4.  Please give it a try!

 Kris, thanks for reporting this problem.  Thanks Andy, John and Evan
 for supplying valuable feedback.  Doing the right thing was tricky here.

 Cheers,
 Peter
 --
 http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-14 Thread Peter Bex
On Sat, Jun 07, 2014 at 02:19:22PM +0200, Peter Bex wrote:
 So here's a new poll:
 
 a) The current behaviour of resetting port to #f if it's the default port
  for this scheme is ok.
 b) The port should not be reset, and the uri should be printed with an
 explicit port, even if it's the default for this scheme.
 c) The port should not be reset, but the uri should be printed without
 port if it's the default for this scheme.

I have now implemented c), and tagged release 1.4.  Please give it a try!

Kris, thanks for reporting this problem.  Thanks Andy, John and Evan
for supplying valuable feedback.  Doing the right thing was tricky here.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-10 Thread Kristian Lein-Mathisen
If we go for (b), we could also provide a normalize-uri-port which sets it
to #f if it's already equal to the default port of its scheme. And perhaps
an optional normalize? argument to the uri-string procedure?

K.


On Sun, Jun 8, 2014 at 8:16 PM, Evan Hanson ev...@foldling.org wrote:

 On 2014-06-08 11:14, Peter Bex wrote:
  On Sat, Jun 07, 2014 at 09:01:01PM -0400, John Cowan wrote:
   Peter Bex scripsit:
  
c) The port should not be reset, but the uri should be printed
 without
port if it's the default for this scheme.
  
   +1 for (c).
 
  hm, but if you really want to print http://foo:80/blabla, how
  should that work?

 In that case I don't think it's unreasonable to expect the user to
 define their own function to build a string from the URI's composite
 parts. We have to pick a default behavior one way or the other, and
 without the port seems like the better one to me.

 Regards,

 Evan

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-08 Thread Peter Bex
On Sat, Jun 07, 2014 at 09:01:01PM -0400, John Cowan wrote:
 Peter Bex scripsit:
 
  c) The port should not be reset, but the uri should be printed without
  port if it's the default for this scheme.
 
 +1 for (c).

hm, but if you really want to print http://foo:80/blabla, how
should that work?

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-08 Thread John Cowan
Peter Bex scripsit:

 hm, but if you really want to print http://foo:80/blabla, how
 should that work?

Why would you?  It means exactly the same thing as http://foo/blabla
and it's longer.

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
Go, and never darken my towels again!
--Rufus T. Firefly

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-08 Thread Andy Bennett

Hi,


So here's a new poll:

a) The current behaviour of resetting port to #f if it's the default port
 for this scheme is ok.
b) The port should not be reset, and the uri should be printed with an
explicit port, even if it's the default for this scheme.
c) The port should not be reset, but the uri should be printed without
port if it's the default for this scheme.

Once results are in, I'll adjust the behaviour accordingly, and make a
new uri-common release.


My vote is for (b) with the caveat that the port should not be printed if 
it is #f.



Regards,
@ndy

--
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-08 Thread Evan Hanson
On 2014-06-08 11:14, Peter Bex wrote:
 On Sat, Jun 07, 2014 at 09:01:01PM -0400, John Cowan wrote:
  Peter Bex scripsit:
  
   c) The port should not be reset, but the uri should be printed without
   port if it's the default for this scheme.
  
  +1 for (c).
 
 hm, but if you really want to print http://foo:80/blabla, how
 should that work?

In that case I don't think it's unreasonable to expect the user to
define their own function to build a string from the URI's composite
parts. We have to pick a default behavior one way or the other, and
without the port seems like the better one to me.

Regards,

Evan

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-07 Thread Peter Bex
On Wed, May 28, 2014 at 11:18:14AM +0200, Kristian Lein-Mathisen wrote:
 I realize I already put down my vote, but I'd like to promote my case after
 some thought. I guess what we're trying to find out is what's more
 troublesome and/or surprising:
 
 1. having to set the port explicitly (to #f?) when you want to change the
 scheme and its port
 2. having to set the port explicitly back to its original value if you want
 to change scheme but not its port
 
 I don't think it's unreasonable to expect the user to realize he/she has to
 change the port if he/she changes the port (as in 1.). That requires an
 understanding of the relationship between scheme and port by the user.

I've now (finally!) changed the implementation not to switch ports when
changing schemes (in uri-common trunk).  However, taking a look at this
behaviour caused me to question another thing:

If a port is the default port for the scheme, should it be kept around?
Right now, if you do (update-uri uri scheme: 'http port: 80) it will
clear the port.  This is done so that the uri will be printed as
http://foo/bar rather than http://foo:80/bar, which would be redundant.

Unfortunately, that also means that (uri-port (update-uri uri port: x))
may return either x or #f.  And if you
(update-uri (update-uri uri port: 80 scheme: 'http) scheme: 'https) that
will result in the port not being 80.

I can keep it like this, but I can also keep around the selected port.
If that's done, it can still be decided to print the URI as
http://foo/bar even if the (uri-port uri) returns 80.

So here's a new poll:

a) The current behaviour of resetting port to #f if it's the default port
 for this scheme is ok.
b) The port should not be reset, and the uri should be printed with an
explicit port, even if it's the default for this scheme.
c) The port should not be reset, but the uri should be printed without
port if it's the default for this scheme.

Once results are in, I'll adjust the behaviour accordingly, and make a
new uri-common release.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-06-07 Thread John Cowan
Peter Bex scripsit:

 c) The port should not be reset, but the uri should be printed without
 port if it's the default for this scheme.

+1 for (c).

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
Is a chair finely made tragic or comic? Is the portrait of Mona Lisa
good if I desire to see it? Is the bust of Sir Philip Crampton lyrical,
epical or dramatic?  If a man hacking in fury at a block of wood make
there an image of a cow, is that image a work of art? If not, why not?
--Stephen Dedalus

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-28 Thread Kristian Lein-Mathisen
I realize I already put down my vote, but I'd like to promote my case after
some thought. I guess what we're trying to find out is what's more
troublesome and/or surprising:

1. having to set the port explicitly (to #f?) when you want to change the
scheme and its port
2. having to set the port explicitly back to its original value if you want
to change scheme but not its port

I don't think it's unreasonable to expect the user to realize he/she has to
change the port if he/she changes the port (as in 1.). That requires an
understanding of the relationship between scheme and port by the user.

I do, however, think it's more unreasonable to expect the user to realize
he/she has to change the port back to its original value if he wants to
change the scheme but not the port. In this case, you need to understand
the internals of uri-common. (You need to understand the scheme-port
relationship as well to make sense of the API). I also think it's
unfortunate that you cannot simply look at the keywords in update-uri and
know exactly which fields are modified by quick glance.

Thanks for considering the change :) my vote's on 1.
K.


On Fri, May 16, 2014 at 3:35 PM, Andy Bennett andy...@ashurst.eu.orgwrote:

 On Friday, 16 May 2014 14:28:51 BST, Andy Bennett wrote:

 Hi,

  If anyone on this mailinglist has strong opinions either way, please let
 yourselves be heard: now's the time to speak up.


 The existing behaviour seems reasonable as it only does it when setting
 scheme, not when setting other parts of the URI:

 -
 #;3 (update-uri (uri-reference http://localhost:8080/;) scheme: 'https)
 #URI-common: scheme=https port=#f host=localhost path=(/ ) query=()
 fragment=#f
 #;4 (update-uri (uri-reference http://localhost:8080/;) fragment:
 test)
 #URI-common: scheme=http port=8080 host=localhost path=(/ ) query=()
 fragment=test
 -




 Regards,
 @ndy

 --
 andy...@ashurst.eu.org
 http://www.ashurst.eu.org/
 0x7EBA75FF

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-16 Thread Andy Bennett

Hi,


If anyone on this mailinglist has strong opinions either way, please let
yourselves be heard: now's the time to speak up.


If there was a vote then I'd vote to preserve an explicit port setting but 
dynamically choose the correct one, based on scheme, when port is #f.


I don't think we (Knodium) rely on the current behaviour.

We do use the domain canonicalisation examples: 
http://api.call-cc.org/doc/spiffy#sec:Redirecting_to_another_domain
The latter one is reasonably robust in the face of both the current 
behaviour and KLM's proposed behaviour. The former one is not.






Regards,
@ndy

--
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-16 Thread Andy Bennett

On Friday, 16 May 2014 14:28:51 BST, Andy Bennett wrote:

Hi,


If anyone on this mailinglist has strong opinions either way, please let
yourselves be heard: now's the time to speak up.


The existing behaviour seems reasonable as it only does it when setting 
scheme, not when setting other parts of the URI:


-
#;3 (update-uri (uri-reference http://localhost:8080/;) scheme: 'https)
#URI-common: scheme=https port=#f host=localhost path=(/ ) query=() 
fragment=#f

#;4 (update-uri (uri-reference http://localhost:8080/;) fragment: test)
#URI-common: scheme=http port=8080 host=localhost path=(/ ) query=() 
fragment=test

-



Regards,
@ndy

--
andy...@ashurst.eu.org
http://www.ashurst.eu.org/
0x7EBA75FF

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] bug update-uri in uri-common

2014-05-13 Thread Kristian Lein-Mathisen
Hi guys,

I have come across som a bug or unintuitive behaviour in uri-common. The
port parameter is reset on update-uri. uri-generic works like expected:

csi -R uri-generic
#;1 (update-uri (make-uri port: 100) scheme: 'http)
#(URI scheme=http authority=#(URIAuth host=#f port=100) path=() query=#f
fragment=#f)

however, uri-common sets the port back to #f:

csi -R uri-common
#;1 (update-uri (make-uri port: 100) scheme: 'http)
#URI-common: scheme=http port=#f host=#f path=#f query=#f fragment=#f

I'm expecting to see port: 100 in the updated uri. A fairly simple
workaround is, of course, adding port: (uri-port original-uri) but I
thought I'd point this out.

Thanks,
K.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-13 Thread Peter Bex
On Tue, May 13, 2014 at 01:38:16PM +0200, Kristian Lein-Mathisen wrote:
 Hi guys,
 
 I have come across som a bug or unintuitive behaviour in uri-common. The
 port parameter is reset on update-uri. uri-generic works like expected:
 
 csi -R uri-generic
 #;1 (update-uri (make-uri port: 100) scheme: 'http)
 #(URI scheme=http authority=#(URIAuth host=#f port=100) path=() query=#f
 fragment=#f)
 
 however, uri-common sets the port back to #f:
 
 csi -R uri-common
 #;1 (update-uri (make-uri port: 100) scheme: 'http)
 #URI-common: scheme=http port=#f host=#f path=#f query=#f fragment=#f
 
 I'm expecting to see port: 100 in the updated uri. A fairly simple
 workaround is, of course, adding port: (uri-port original-uri) but I
 thought I'd point this out.

I don't remember exactly, but I think this is intended behaviour.
This allows you to switch from http to https without also having to
update the port to something else.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-13 Thread Kristian Lein-Mathisen
Hmmm ... The scheme is changed, like you say, but the port is too, from 100
to #f, which is what I find surprising.

I cannot seem to find a way to update the uri without loosing the port.
What am doing wrong here?

K.
On May 13, 2014 1:48 PM, Peter Bex peter@xs4all.nl wrote:

 On Tue, May 13, 2014 at 01:38:16PM +0200, Kristian Lein-Mathisen wrote:
  Hi guys,
 
  I have come across som a bug or unintuitive behaviour in uri-common. The
  port parameter is reset on update-uri. uri-generic works like expected:
 
  csi -R uri-generic
  #;1 (update-uri (make-uri port: 100) scheme: 'http)
  #(URI scheme=http authority=#(URIAuth host=#f port=100) path=() query=#f
  fragment=#f)
 
  however, uri-common sets the port back to #f:
 
  csi -R uri-common
  #;1 (update-uri (make-uri port: 100) scheme: 'http)
  #URI-common: scheme=http port=#f host=#f path=#f query=#f fragment=#f
 
  I'm expecting to see port: 100 in the updated uri. A fairly simple
  workaround is, of course, adding port: (uri-port original-uri) but I
  thought I'd point this out.

 I don't remember exactly, but I think this is intended behaviour.
 This allows you to switch from http to https without also having to
 update the port to something else.

 Cheers,
 Peter
 --
 http://www.more-magic.net

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-13 Thread Peter Bex
On Tue, May 13, 2014 at 11:25:23PM +0200, Kristian Lein-Mathisen wrote:
 Hmmm ... The scheme is changed, like you say, but the port is too, from 100
 to #f, which is what I find surprising.
 
 I cannot seem to find a way to update the uri without loosing the port.
 What am doing wrong here?

Try updating it simultaneously.  This should work:

(update-uri foo scheme: 'http port: 100)

The idea is that you'd rarely want to switch to an entirely different
protocol on the same port anyway, so the sane thing to do is reset it to
the default.

If this doesn't work either, it would be a bug.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-13 Thread Kristian Lein-Mathisen
A, of course, now I understand what you were trying to tell me previously.
That makes sense. Thanks for clarifying, Peter.

In my particular use-case, I am changing to a custom scheme and this port
clear on scheme change feature made me scratch my head for a while (but
that happens quite often, so is no indicator if whether the api is
intuitive or not!). So if we were to vote, it'd put my two cents on not
modifying the port unless explicitly stated (if it's already #f it's still
work like you'd expect).

K.
On May 13, 2014 11:28 PM, Peter Bex peter@xs4all.nl wrote:

 On Tue, May 13, 2014 at 11:25:23PM +0200, Kristian Lein-Mathisen wrote:
  Hmmm ... The scheme is changed, like you say, but the port is too, from
 100
  to #f, which is what I find surprising.
 
  I cannot seem to find a way to update the uri without loosing the port.
  What am doing wrong here?

 Try updating it simultaneously.  This should work:

 (update-uri foo scheme: 'http port: 100)

 The idea is that you'd rarely want to switch to an entirely different
 protocol on the same port anyway, so the sane thing to do is reset it to
 the default.

 If this doesn't work either, it would be a bug.

 Cheers,
 Peter
 --
 http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-13 Thread Peter Bex
On Tue, May 13, 2014 at 11:37:53PM +0200, Kristian Lein-Mathisen wrote:
 A, of course, now I understand what you were trying to tell me previously.
 That makes sense. Thanks for clarifying, Peter.

Glad my ramblings were helpful!

 In my particular use-case, I am changing to a custom scheme and this port
 clear on scheme change feature made me scratch my head for a while (but
 that happens quite often, so is no indicator if whether the api is
 intuitive or not!). So if we were to vote, it'd put my two cents on not
 modifying the port unless explicitly stated (if it's already #f it's still
 work like you'd expect).

You're probably right, it's an example of more magic (the bad kind!).
But this is a breaking change, so I'll have to think about it for a bit.

If anyone on this mailinglist has strong opinions either way, please let
yourselves be heard: now's the time to speak up.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] bug update-uri in uri-common

2014-05-13 Thread John Cowan
Peter Bex scripsit:

 If anyone on this mailinglist has strong opinions either way, please let
 yourselves be heard: now's the time to speak up.

I think the existing behavior is correct, because scheme and port are
tied together.

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
The Imperials are decadent, 300 pound   John Cowan co...@ccil.org
free-range chickens (except they have   http://www.ccil.org/~cowan
teeth, arms instead of wings, and
dinosaurlike tails).--Elyse Grasso

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users