About HTTP proxies, settings and MacOS

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

About HTTP proxies, settings and MacOS

Mariano Martinez Peck
Hi guys. Few weeks ago, there was an issue about Zn and HTTP proxies. I am in MacOS and behind a proxy. Before that issue, I was able to DIRECTLY connect to internet without specifying anything at the image level.
This is because, I guess, the VM and somehow the image I guess, took the default proxy settings I have in MacOS.

Now, with the last version of Pharo 1.3 I need to explicitly set the proxy in order to go to internet. So, first question, is that expected?

Second question, if I go to the settings browser, Network -> Use HTTP proxy,  if I check the box, it AUTOMATICALLY shows me the correct data: IP + port. So it seems it is getting it automatically from the MacOS specification. When enabling the checkbox, I can use internet.

However, I still need to go there and set it and I am a lazy guy ;)   So my question is....is there a way to avoid having to set this?  I mean, if you could detect that there was a proxy IP and port, why not to use it directly? is this on purpose?

Thanks

--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

laurent laffont
I remember http://code.google.com/p/pharo/wiki/CommentOfTheDayContest#61_-_InternetConfiguration_-_L.Laffont,_M.Denker

May help.

Laurent.

On Tue, Jun 28, 2011 at 10:28 AM, Mariano Martinez Peck <[hidden email]> wrote:
Hi guys. Few weeks ago, there was an issue about Zn and HTTP proxies. I am in MacOS and behind a proxy. Before that issue, I was able to DIRECTLY connect to internet without specifying anything at the image level.
This is because, I guess, the VM and somehow the image I guess, took the default proxy settings I have in MacOS.

Now, with the last version of Pharo 1.3 I need to explicitly set the proxy in order to go to internet. So, first question, is that expected?

Second question, if I go to the settings browser, Network -> Use HTTP proxy,  if I check the box, it AUTOMATICALLY shows me the correct data: IP + port. So it seems it is getting it automatically from the MacOS specification. When enabling the checkbox, I can use internet.

However, I still need to go there and set it and I am a lazy guy ;)   So my question is....is there a way to avoid having to set this?  I mean, if you could detect that there was a proxy IP and port, why not to use it directly? is this on purpose?

Thanks

--
Mariano
http://marianopeck.wordpress.com


Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Marcus Denker-4
In reply to this post by Mariano Martinez Peck

On Jun 28, 2011, at 10:29 AM, Mariano Martinez Peck wrote:

> Hi guys. Few weeks ago, there was an issue about Zn and HTTP proxies. I am in MacOS and behind a proxy. Before that issue, I was able to DIRECTLY connect to internet without specifying anything at the image level.
> This is because, I guess, the VM and somehow the image I guess, took the default proxy settings I have in MacOS.
>
> Now, with the last version of Pharo 1.3 I need to explicitly set the proxy in order to go to internet. So, first question, is that expected?
>

No.

> Second question, if I go to the settings browser, Network -> Use HTTP proxy,  if I check the box, it AUTOMATICALLY shows me the correct data: IP + port. So it seems it is getting it automatically from the MacOS specification. When enabling the checkbox, I can use internet.
>
> However, I still need to go there and set it and I am a lazy guy ;)   So my question is....is there a way to avoid having to set this?  I mean, if you could detect that there was a proxy IP and port, why not to use it directly? is this on purpose?
>




--
Marcus Denker  -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.


Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Marcus Denker-4

On Jun 28, 2011, at 11:10 AM, Marcus Denker wrote:

>
> On Jun 28, 2011, at 10:29 AM, Mariano Martinez Peck wrote:
>
>> Hi guys. Few weeks ago, there was an issue about Zn and HTTP proxies. I am in MacOS and behind a proxy. Before that issue, I was able to DIRECTLY connect to internet without specifying anything at the image level.
>> This is because, I guess, the VM and somehow the image I guess, took the default proxy settings I have in MacOS.
>>
>> Now, with the last version of Pharo 1.3 I need to explicitly set the proxy in order to go to internet. So, first question, is that expected?
>>
>
> No.
>
>> Second question, if I go to the settings browser, Network -> Use HTTP proxy,  if I check the box, it AUTOMATICALLY shows me the correct data: IP + port. So it seems it is getting it automatically from the MacOS specification. When enabling the checkbox, I can use internet.
>>

We need to rewrite this:

InternetConfiguration>>startUp
        OSPlatform isMacOS ifTrue: [
                self useHTTPProxy ifTrue: [
                         (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [:p |
                          HTTPSocket useProxyServerNamed: p first port: p second asInteger]]]

For Zinc.


--
Marcus Denker  -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.


Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Sven Van Caekenberghe

On 28 Jun 2011, at 11:12, Marcus Denker wrote:

> We need to rewrite this:
>
> InternetConfiguration>>startUp
> OSPlatform isMacOS ifTrue: [
> self useHTTPProxy ifTrue: [
> (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [:p |
> HTTPSocket useProxyServerNamed: p first port: p second asInteger]]]
>
> For Zinc.

Since (which is now in 1.3 already):

---
Name: Zinc-HTTP-SvenVanCaekenberghe.164
Author: SvenVanCaekenberghe
Time: 17 June 2011, 9:16:22 am
UUID: 90d57d3d-fc41-4548-a2fd-dcd7c22a3a1f
Ancestors: Zinc-HTTP-SvenVanCaekenberghe.163

implemented support for proxies that require authorization;
ZnHeaders class>>#requestHeadersFor: will add a Proxy-Authorization header when needed;
added public API ZnNetworkingUtils class>>#proxyAuthorizationHeaderValueToUrl:
removed public API ZnNetworkingUtils class>>#httpProxy and #isProxySet;
upgraded public API ZnNetworkingUtils class>>#shouldProxyUrl: to be a primary interface;
refactored internals of ZnNetworkUtils to use NetworkSystemSettings directly instead of HTTPSocket;

this code still has to be tested and validated with real world proxies
---

Zn is no longer using HTTPSocket as authorative source for the proxy settings info, but is using NetworkSystemSettings. This was necessary to get the info for authenticated proxies. Also, we should not depend on HTTPSocket if we can avoid it.

So yes, it seems as if the code that Marcus showed needs to modify NetworkSystemSettings, which would fix Mariono's issues.


Sven


Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Sven Van Caekenberghe
In reply to this post by Marcus Denker-4

On 28 Jun 2011, at 11:12, Marcus Denker wrote:

> InternetConfiguration>>startUp
> OSPlatform isMacOS ifTrue: [
> self useHTTPProxy ifTrue: [
> (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [:p |
> HTTPSocket useProxyServerNamed: p first port: p second asInteger]]]

After browsing the code a bit, adding

        NetworkSystemSettings useHTTPProxy: true

inside the ifNotEmpty: as last statement might already help.

It would be cleaner to no longer reference HTTPSocket here and add use NetworkSystemSettings. The silly thing is that currently, NetworkSystemSettings itself falls back to HTTPSocket for the proxy host and port, for backwards compatibility reasons no doubt. Still, the abstraction/indirection would be good. So then it the code would be

        NetworkSystemSettings
                httpProxyServer: p first;
                httpProxyPort: p second asInteger;
                useHTTPProxy: true

As sole contents of the ifNotEmpty:

But since I am not behind a proxy, this must still be tested by someone who is.

Regards,

Sven



Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Denis Kudriashov
In reply to this post by Sven Van Caekenberghe
Is Zinc-HTTP supports NTLM proxy authentication?

2011/6/28 Sven Van Caekenberghe <[hidden email]>
Name: Zinc-HTTP-SvenVanCaekenberghe.164
Author: SvenVanCaekenberghe
Time: 17 June 2011, 9:16:22 am
UUID: 90d57d3d-fc41-4548-a2fd-dcd7c22a3a1f
Ancestors: Zinc-HTTP-SvenVanCaekenberghe.163

implemented support for proxies that require authorization;
ZnHeaders class>>#requestHeadersFor: will add a Proxy-Authorization header when needed;
added public API ZnNetworkingUtils class>>#proxyAuthorizationHeaderValueToUrl:
removed public API ZnNetworkingUtils class>>#httpProxy and #isProxySet;
upgraded public API ZnNetworkingUtils class>>#shouldProxyUrl: to be a primary interface;
refactored internals of ZnNetworkUtils to use NetworkSystemSettings directly instead of HTTPSocket;

this code still has to be tested and validated with real world proxies
---

Zn is no longer using HTTPSocket as authorative source for the proxy settings info, but is using NetworkSystemSettings. This was necessary to get the info for authenticated proxies. Also, we should not depend on HTTPSocket if we can avoid it.

So yes, it seems as if the code that Marcus showed needs to modify NetworkSystemSettings, which would fix Mariono's issues.


Sven



Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Sven Van Caekenberghe

On 28 Jun 2011, at 21:05, Denis Kudriashov wrote:

> Is Zinc-HTTP supports NTLM proxy authentication?

No, it is not.

This also seems like a older MS only technology, but I might be wrong.

Code contributions are always welcome of course.

Sven


Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Mariano Martinez Peck
In reply to this post by Sven Van Caekenberghe


On Tue, Jun 28, 2011 at 12:13 PM, Sven Van Caekenberghe <[hidden email]> wrote:

On 28 Jun 2011, at 11:12, Marcus Denker wrote:

> InternetConfiguration>>startUp
>       OSPlatform isMacOS ifTrue: [
>               self useHTTPProxy ifTrue: [
>                        (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [:p |
>                               HTTPSocket useProxyServerNamed: p first port: p second asInteger]]]

After browsing the code a bit, adding

       NetworkSystemSettings useHTTPProxy: true 

inside the ifNotEmpty: as last statement might already help.


Thanks Sven, that worked :)
Thanks Marcus for pointing us to the right place to fix it.

Can we integrate it marcus for 1.3?

 
It would be cleaner to no longer reference HTTPSocket here and add use NetworkSystemSettings. The silly thing is that currently, NetworkSystemSettings itself falls back to HTTPSocket for the proxy host and port, for backwards compatibility reasons no doubt. Still, the abstraction/indirection would be good. So then it the code would be

       NetworkSystemSettings
               httpProxyServer: p first;
               httpProxyPort: p second asInteger;
               useHTTPProxy: true

As sole contents of the ifNotEmpty:

But since I am not behind a proxy, this must still be tested by someone who is.

Regards,

Sven






--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Marcus Denker-4
In reply to this post by Sven Van Caekenberghe
> Thanks Sven, that worked :)
> Thanks Marcus for pointing us to the right place to fix it.
>
> Can we integrate it marcus for 1.3?
>
>

Yes! please add something machine readable to the bug tracker issue:

   http://code.google.com/p/pharo/issues/detail?id=4473

--
Marcus Denker  --  [hidden email]
http://www.marcusdenker.de

Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Mariano Martinez Peck
So...now if I save the image in a place where I have a proxy (my work) and then I try to open it in another place that has no proxy (my home), it doesn't work. To solve that I did:

startUp
    OSPlatform isMacOS ifTrue: [
        self useHTTPProxy ifTrue: [
             (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [:p |
                NetworkSystemSettings useHTTPProxy: true.
                 HTTPSocket useProxyServerNamed: p first port: p second asInteger]]
        ifFalse: [HTTPSocket stopUsingProxyServer.
            NetworkSystemSettings useHTTPProxy: false]]


I added the ifFalse part to reset it.

What do you think? At least it seems to work for me.

Thanks

On Wed, Jun 29, 2011 at 10:14 AM, Marcus Denker <[hidden email]> wrote:
> Thanks Sven, that worked :)
> Thanks Marcus for pointing us to the right place to fix it.
>
> Can we integrate it marcus for 1.3?
>
>

Yes! please add something machine readable to the bug tracker issue:

  http://code.google.com/p/pharo/issues/detail?id=4473

--
Marcus Denker  --  [hidden email]
http://www.marcusdenker.de




--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Sven Van Caekenberghe

On 29 Jun 2011, at 14:17, Mariano Martinez Peck wrote:

> What do you think? At least it seems to work for me.

I added a fileout to the issue,  http://code.google.com/p/pharo/issues/detail?id=4473

Mariano, please try once more before we include it...

Sven


cbc
Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

cbc
In reply to this post by Mariano Martinez Peck
On Wed, Jun 29, 2011 at 5:17 AM, Mariano Martinez Peck
<[hidden email]> wrote:

> So...now if I save the image in a place where I have a proxy (my work) and
> then I try to open it in another place that has no proxy (my home), it
> doesn't work. To solve that I did:
>
> startUp
>     OSPlatform isMacOS ifTrue: [
>         self useHTTPProxy ifTrue: [
>              (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [:p |
>                 NetworkSystemSettings useHTTPProxy: true.
>                  HTTPSocket useProxyServerNamed: p first port: p second
> asInteger]]
>         ifFalse: [HTTPSocket stopUsingProxyServer.
>             NetworkSystemSettings useHTTPProxy: false]]
>

Am I reading this right?  If I was on, say, Windows behind a proxy,
this would disable proxy use on startup?  So, every time I started an
image, I would have to manually re-enable proxy use?

Would there be a way to detect if the proxy still exists on startUp,
and if it doesn't, then temporarily disable the proxy instead?

-Chris

Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Marcus Denker-4
In reply to this post by Mariano Martinez Peck

On Jun 29, 2011, at 8:25 PM, Chris Cunningham wrote:

> On Wed, Jun 29, 2011 at 5:17 AM, Mariano Martinez Peck
> <[hidden email]> wrote:
>> So...now if I save the image in a place where I have a proxy (my work) and
>> then I try to open it in another place that has no proxy (my home), it
>> doesn't work. To solve that I did:
>>
>> startUp
>>     OSPlatform isMacOS ifTrue: [
>>         self useHTTPProxy ifTrue: [
>>              (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [:p |
>>                 NetworkSystemSettings useHTTPProxy: true.
>>                  HTTPSocket useProxyServerNamed: p first port: p second
>> asInteger]]
>>         ifFalse: [HTTPSocket stopUsingProxyServer.
>>             NetworkSystemSettings useHTTPProxy: false]]
>>
>
> Am I reading this right?  If I was on, say, Windows behind a proxy,
> this would disable proxy use on startup?  So, every time I started an
> image, I would have to manually re-enable proxy use?
>

This is not good.

InternetConfiguration has a method called on image save that removes the proxy on
the mac:

shutDown
        OSPlatform isMacOS
                ifTrue: [ HTTPSocket stopUsingProxyServer ]
       
startUp should not mess with the proxy on other systems.


> Would there be a way to detect if the proxy still exists on startUp,
> and if it doesn't, then temporarily disable the proxy instead?

It's the duty of the OS to provide proxy info, and the duty of the VM to provide
this to the Image. Till today, this exists only on the Mac.

        Marcus

--
Marcus Denker  -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.


Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

Sven Van Caekenberghe
In reply to this post by cbc

On 29 Jun 2011, at 20:25, Chris Cunningham wrote:

> Am I reading this right?  If I was on, say, Windows behind a proxy,
> this would disable proxy use on startup?  So, every time I started an
> image, I would have to manually re-enable proxy use?

Uhh, no, on Windows nothing at all would happen, this is Mariano's code, as I formatted it:

startUp
        OSPlatform isMacOS
                ifTrue: [
                        self useHTTPProxy
                                ifTrue: [
                                        (self getHTTPProxyHost findTokens: ':') ifNotEmpty: [ :p |
                          NetworkSystemSettings
                                                        httpProxyServer: p first;
                                                        httpProxyPort: p second asInteger;
                                                        useHTTPProxy: true ] ]
                                ifFalse: [
                                        NetworkSystemSettings useHTTPProxy: false ] ]

This does not take away anything that wasn't there before, as far as I can see.

Sven


cbc
Reply | Threaded
Open this post in threaded view
|

Re: About HTTP proxies, settings and MacOS

cbc
On Wed, Jun 29, 2011 at 12:17 PM, Sven Van Caekenberghe <[hidden email]> wrote:
>
> On 29 Jun 2011, at 20:25, Chris Cunningham wrote:
>
>> Am I reading this right?  If I was on, say, Windows behind a proxy,
>> this would disable proxy use on startup?  So, every time I started an
>> image, I would have to manually re-enable proxy use?
>
> Uhh, no, on Windows nothing at all would happen, this is Mariano's code, as I formatted it:
>
Good.  I did read it wrong.