Re: [racket-users] HTTPS connection through proxy (CONNECT HTTP Method)

2016-08-31 Thread P. Baillet
For the newcomers like me, a small update here to say that proxy support has 
almost landed in racket. https://github.com/racket/racket/pull/1411

Being behind a corporate firewall, I'm eager to test that!

Cheers,
Pierre.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-17 Thread Jay McCarthy
It sounds like you are on the right track. If you need help and can
provide a test case, then I'd be able to be more useful. I think the
function you're going to want to get out is something like:

http-conn-tunnel/ssl : http-conn [arguments to ports-ssl-ports] - http-conn

where the input port is a plain HTTP port and the one that comes out
is the SSL version. Then you'd use the second one to actually make the
requests.

From your email, I can't tell if you are using the results from
ports-ssl-ports back in a new http-conn object.

Another design decision would be whether the tunnel/ssl function makes
the CONNECT call too. But for now, you should just assume not and just
return a new http-conn object assuming the connect has been done.

Jay

On Fri, Aug 14, 2015 at 5:01 PM, Sean Kemplay sean.kemp...@gmail.com wrote:
 On Friday, August 14, 2015 at 3:41:04 PM UTC+1, Sean Kemplay wrote:
 On Friday, August 14, 2015 at 10:22:03 AM UTC+1, Sean Kemplay wrote:
  On Wednesday, August 12, 2015 at 9:54:23 PM UTC+1, Sean Kemplay wrote:
   On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay 
sean.kemp...@gmail.com wrote:
 Hi All,

 Sending an http request through our corporate proxy works as follows 
 for http requests -

 (define-values (x y z)
   (http-sendrecv 10.0.0.200 http://www.example.com;
  #:port 8080
  #:headers '(
  Proxy-Authorization: Basic 
 base64encodedcredentials
  Proxy-Connections: 
 keep-alive
  )
  #:ssl? #f
  #:method GET))

 However fails for HTTPS requests (as expected).

 What I need to do is make a request like the above using the 
 #:method CONNECT and then make a secondary request through a 
 returned connection.

 Does anyone know how I would go about doing that in Racket?
   
http-sendrecv combines calls to http-conn-open, http-conn-send!,
http-conn-recv!, then http-conn-close!. I suspect that you just need
to break up that one big call into a few calls like open, send, recv,
send, recv, close. I'd be happy to work on it with you, but I don't
have such a proxy on hand, so I'll need helping testing it.
   
Jay
   

 Kind regards,
 Sean

 --
 You received this message because you are subscribed to the Google 
 Groups Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, 
 send an email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
   
   
   
--
Jay McCarthy
http://jeapostrophe.github.io
   
   Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great.
  - DC 64:33
  
   Hi Jay,
  
   Thanks for that, yes I think you are right. I have just installed squid 
   at home which also supports http tunnelling. I'll see how I get on and 
   post my results - whether they be good or bad!
  
   It would be really good to at least get an example on the wiki for 
   others to build from, as I suspect a lot of corporate networks are 
   behind proxies and this would be problematic in using Racket to make 
   calls to REST APIs etc which my job at least requires a lot of.
  
   Kind regards,
   Sean
 
  Hi Jay,
 
  Unfortunately I am not getting very far with this.
 
  Our app servers where our production code sits are not behind a proxy, so 
  at the end of the day it doesn't rule out using Racket for some of the 
  tasks I have in mind. It would be nice to be able to get through the proxy 
  from my desktop to test code though.
 
  I tried the following but the connection is ending early -
 
  #lang racket
  (require net/http-client)
 
  (define conn (http-conn-open 10.0.0.200 #:port 8080))
 
  (http-conn-send! conn https://news.ycombinator.com/; #:method CONNECT 
  #:headers '(Proxy-Authorization: Basic base64encodedcredentials 
  Connection: Keep-Alive) #:version #1.1)
  (define-values (a b c)(http-conn-recv! conn #:close? #f))
  (http-conn-send! conn / #:method GET); #:headers 
  '(Proxy-Authorization: Basic Y3hnXHNlYW4ua2VtcGxheTpBdWd1c3QyMDE0 
  Connection: Keep-Alive) #:version #1.1)
  (define-values (e f g) (http-conn-recv! conn))
  (http-conn-close! conn)
 
  I am basing the above on this S/O post but am not entirely sure if this is 
  even the path I should be pursuing!
 
  http://stackoverflow.com/questions/11697943/when-should-one-use-connect-and-get-http-methods-at-http-proxy-server
 
  Here is an example using Node, it opens the connection to the uri through 
  the proxy, then writes to that connection through an SSL connection which 
 

Re: [racket-users] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-14 Thread Sean Kemplay
On Wednesday, August 12, 2015 at 9:54:23 PM UTC+1, Sean Kemplay wrote:
 On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
  On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com 
  wrote:
   Hi All,
  
   Sending an http request through our corporate proxy works as follows for 
   http requests -
  
   (define-values (x y z)
 (http-sendrecv 10.0.0.200 http://www.example.com;
#:port 8080
#:headers '(
Proxy-Authorization: Basic 
   base64encodedcredentials
Proxy-Connections: keep-alive
)
#:ssl? #f
#:method GET))
  
   However fails for HTTPS requests (as expected).
  
   What I need to do is make a request like the above using the #:method 
   CONNECT and then make a secondary request through a returned connection.
  
   Does anyone know how I would go about doing that in Racket?
  
  http-sendrecv combines calls to http-conn-open, http-conn-send!,
  http-conn-recv!, then http-conn-close!. I suspect that you just need
  to break up that one big call into a few calls like open, send, recv,
  send, recv, close. I'd be happy to work on it with you, but I don't
  have such a proxy on hand, so I'll need helping testing it.
  
  Jay
  
  
   Kind regards,
   Sean
  
   --
   You received this message because you are subscribed to the Google Groups 
   Racket Users group.
   To unsubscribe from this group and stop receiving emails from it, send an 
   email to racket-users+unsubscr...@googlegroups.com.
   For more options, visit https://groups.google.com/d/optout.
  
  
  
  -- 
  Jay McCarthy
  http://jeapostrophe.github.io
  
 Wherefore, be not weary in well-doing,
for ye are laying the foundation of a great work.
  And out of small things proceedeth that which is great.
- DC 64:33
 
 Hi Jay,
 
 Thanks for that, yes I think you are right. I have just installed squid at 
 home which also supports http tunnelling. I'll see how I get on and post my 
 results - whether they be good or bad!
 
 It would be really good to at least get an example on the wiki for others to 
 build from, as I suspect a lot of corporate networks are behind proxies and 
 this would be problematic in using Racket to make calls to REST APIs etc 
 which my job at least requires a lot of.
 
 Kind regards,
 Sean

Hi Jay,

Unfortunately I am not getting very far with this.

Our app servers where our production code sits are not behind a proxy, so at 
the end of the day it doesn't rule out using Racket for some of the tasks I 
have in mind. It would be nice to be able to get through the proxy from my 
desktop to test code though.

I tried the following but the connection is ending early -

#lang racket
(require net/http-client)

(define conn (http-conn-open 10.0.0.200 #:port 8080))

(http-conn-send! conn https://news.ycombinator.com/; #:method CONNECT 
#:headers '(Proxy-Authorization: Basic base64encodedcredentials Connection: 
Keep-Alive) #:version #1.1)
(define-values (a b c)(http-conn-recv! conn #:close? #f))
(http-conn-send! conn / #:method GET); #:headers '(Proxy-Authorization: 
Basic Y3hnXHNlYW4ua2VtcGxheTpBdWd1c3QyMDE0 Connection: Keep-Alive) #:version 
#1.1)
(define-values (e f g) (http-conn-recv! conn))
(http-conn-close! conn)

I am basing the above on this S/O post but am not entirely sure if this is even 
the path I should be pursuing!

http://stackoverflow.com/questions/11697943/when-should-one-use-connect-and-get-http-methods-at-http-proxy-server

Here is an example using Node, it opens the connection to the uri through the 
proxy, then writes to that connection through an SSL connection which is 
something I can't see how to do in Racket.

http://blog.vanamco.com/proxy-requests-in-node-js/

I will keep digging, if you have any Ideas or anything I could test against our 
network it would be much appreciated. 

Kind regards,
Sean

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-14 Thread Sean Kemplay
On Friday, August 14, 2015 at 10:22:03 AM UTC+1, Sean Kemplay wrote:
 On Wednesday, August 12, 2015 at 9:54:23 PM UTC+1, Sean Kemplay wrote:
  On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
   On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com 
   wrote:
Hi All,
   
Sending an http request through our corporate proxy works as follows 
for http requests -
   
(define-values (x y z)
  (http-sendrecv 10.0.0.200 http://www.example.com;
 #:port 8080
 #:headers '(
 Proxy-Authorization: Basic 
base64encodedcredentials
 Proxy-Connections: keep-alive
 )
 #:ssl? #f
 #:method GET))
   
However fails for HTTPS requests (as expected).
   
What I need to do is make a request like the above using the #:method 
CONNECT and then make a secondary request through a returned 
connection.
   
Does anyone know how I would go about doing that in Racket?
   
   http-sendrecv combines calls to http-conn-open, http-conn-send!,
   http-conn-recv!, then http-conn-close!. I suspect that you just need
   to break up that one big call into a few calls like open, send, recv,
   send, recv, close. I'd be happy to work on it with you, but I don't
   have such a proxy on hand, so I'll need helping testing it.
   
   Jay
   
   
Kind regards,
Sean
   
--
You received this message because you are subscribed to the Google 
Groups Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
   
   
   
   -- 
   Jay McCarthy
   http://jeapostrophe.github.io
   
  Wherefore, be not weary in well-doing,
 for ye are laying the foundation of a great work.
   And out of small things proceedeth that which is great.
 - DC 64:33
  
  Hi Jay,
  
  Thanks for that, yes I think you are right. I have just installed squid at 
  home which also supports http tunnelling. I'll see how I get on and post my 
  results - whether they be good or bad!
  
  It would be really good to at least get an example on the wiki for others 
  to build from, as I suspect a lot of corporate networks are behind proxies 
  and this would be problematic in using Racket to make calls to REST APIs 
  etc which my job at least requires a lot of.
  
  Kind regards,
  Sean
 
 Hi Jay,
 
 Unfortunately I am not getting very far with this.
 
 Our app servers where our production code sits are not behind a proxy, so at 
 the end of the day it doesn't rule out using Racket for some of the tasks I 
 have in mind. It would be nice to be able to get through the proxy from my 
 desktop to test code though.
 
 I tried the following but the connection is ending early -
 
 #lang racket
 (require net/http-client)
 
 (define conn (http-conn-open 10.0.0.200 #:port 8080))
 
 (http-conn-send! conn https://news.ycombinator.com/; #:method CONNECT 
 #:headers '(Proxy-Authorization: Basic base64encodedcredentials 
 Connection: Keep-Alive) #:version #1.1)
 (define-values (a b c)(http-conn-recv! conn #:close? #f))
 (http-conn-send! conn / #:method GET); #:headers '(Proxy-Authorization: 
 Basic Y3hnXHNlYW4ua2VtcGxheTpBdWd1c3QyMDE0 Connection: Keep-Alive) 
 #:version #1.1)
 (define-values (e f g) (http-conn-recv! conn))
 (http-conn-close! conn)
 
 I am basing the above on this S/O post but am not entirely sure if this is 
 even the path I should be pursuing!
 
 http://stackoverflow.com/questions/11697943/when-should-one-use-connect-and-get-http-methods-at-http-proxy-server
 
 Here is an example using Node, it opens the connection to the uri through the 
 proxy, then writes to that connection through an SSL connection which is 
 something I can't see how to do in Racket.
 
 http://blog.vanamco.com/proxy-requests-in-node-js/
 
 I will keep digging, if you have any Ideas or anything I could test against 
 our network it would be much appreciated. 
 
 Kind regards,
 Sean

Just an update on this, looking at the code for http-client I now understand 
that http-conn is a struct with an input and output port from a tcp connection.

Based on the node.js example I am thinking of instead of calling 
http-conn-send! a second time with a different method I need to write a 
function along the lines of http-conn-tunnel! which somehow pipes ssl input and 
output ports from the tcp input and output ports from http-conn's input and 
output pipes.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit 

Re: [racket-users] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-14 Thread Sean Kemplay
On Friday, August 14, 2015 at 3:41:04 PM UTC+1, Sean Kemplay wrote:
 On Friday, August 14, 2015 at 10:22:03 AM UTC+1, Sean Kemplay wrote:
  On Wednesday, August 12, 2015 at 9:54:23 PM UTC+1, Sean Kemplay wrote:
   On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com 
wrote:
 Hi All,

 Sending an http request through our corporate proxy works as follows 
 for http requests -

 (define-values (x y z)
   (http-sendrecv 10.0.0.200 http://www.example.com;
  #:port 8080
  #:headers '(
  Proxy-Authorization: Basic 
 base64encodedcredentials
  Proxy-Connections: 
 keep-alive
  )
  #:ssl? #f
  #:method GET))

 However fails for HTTPS requests (as expected).

 What I need to do is make a request like the above using the #:method 
 CONNECT and then make a secondary request through a returned 
 connection.

 Does anyone know how I would go about doing that in Racket?

http-sendrecv combines calls to http-conn-open, http-conn-send!,
http-conn-recv!, then http-conn-close!. I suspect that you just need
to break up that one big call into a few calls like open, send, recv,
send, recv, close. I'd be happy to work on it with you, but I don't
have such a proxy on hand, so I'll need helping testing it.

Jay


 Kind regards,
 Sean

 --
 You received this message because you are subscribed to the Google 
 Groups Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, 
 send an email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
Jay McCarthy
http://jeapostrophe.github.io

   Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great.
  - DC 64:33
   
   Hi Jay,
   
   Thanks for that, yes I think you are right. I have just installed squid 
   at home which also supports http tunnelling. I'll see how I get on and 
   post my results - whether they be good or bad!
   
   It would be really good to at least get an example on the wiki for others 
   to build from, as I suspect a lot of corporate networks are behind 
   proxies and this would be problematic in using Racket to make calls to 
   REST APIs etc which my job at least requires a lot of.
   
   Kind regards,
   Sean
  
  Hi Jay,
  
  Unfortunately I am not getting very far with this.
  
  Our app servers where our production code sits are not behind a proxy, so 
  at the end of the day it doesn't rule out using Racket for some of the 
  tasks I have in mind. It would be nice to be able to get through the proxy 
  from my desktop to test code though.
  
  I tried the following but the connection is ending early -
  
  #lang racket
  (require net/http-client)
  
  (define conn (http-conn-open 10.0.0.200 #:port 8080))
  
  (http-conn-send! conn https://news.ycombinator.com/; #:method CONNECT 
  #:headers '(Proxy-Authorization: Basic base64encodedcredentials 
  Connection: Keep-Alive) #:version #1.1)
  (define-values (a b c)(http-conn-recv! conn #:close? #f))
  (http-conn-send! conn / #:method GET); #:headers 
  '(Proxy-Authorization: Basic Y3hnXHNlYW4ua2VtcGxheTpBdWd1c3QyMDE0 
  Connection: Keep-Alive) #:version #1.1)
  (define-values (e f g) (http-conn-recv! conn))
  (http-conn-close! conn)
  
  I am basing the above on this S/O post but am not entirely sure if this is 
  even the path I should be pursuing!
  
  http://stackoverflow.com/questions/11697943/when-should-one-use-connect-and-get-http-methods-at-http-proxy-server
  
  Here is an example using Node, it opens the connection to the uri through 
  the proxy, then writes to that connection through an SSL connection which 
  is something I can't see how to do in Racket.
  
  http://blog.vanamco.com/proxy-requests-in-node-js/
  
  I will keep digging, if you have any Ideas or anything I could test against 
  our network it would be much appreciated. 
  
  Kind regards,
  Sean
 
 Just an update on this, looking at the code for http-client I now understand 
 that http-conn is a struct with an input and output port from a tcp 
 connection.
 
 Based on the node.js example I am thinking of instead of calling 
 http-conn-send! a second time with a different method I need to write a 
 function along the lines of http-conn-tunnel! which somehow pipes ssl input 
 and output ports from the tcp input and output ports from http-conn's input 
 and output pipes.

I haven't given up... yet!

I exported http-conn-from and 

Re: [racket-users] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-12 Thread Sean Kemplay
On Wednesday, August 12, 2015 at 12:54:10 PM UTC+1, Jay McCarthy wrote:
 On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com wrote:
  Hi All,
 
  Sending an http request through our corporate proxy works as follows for 
  http requests -
 
  (define-values (x y z)
(http-sendrecv 10.0.0.200 http://www.example.com;
   #:port 8080
   #:headers '(
   Proxy-Authorization: Basic 
  base64encodedcredentials
   Proxy-Connections: keep-alive
   )
   #:ssl? #f
   #:method GET))
 
  However fails for HTTPS requests (as expected).
 
  What I need to do is make a request like the above using the #:method 
  CONNECT and then make a secondary request through a returned connection.
 
  Does anyone know how I would go about doing that in Racket?
 
 http-sendrecv combines calls to http-conn-open, http-conn-send!,
 http-conn-recv!, then http-conn-close!. I suspect that you just need
 to break up that one big call into a few calls like open, send, recv,
 send, recv, close. I'd be happy to work on it with you, but I don't
 have such a proxy on hand, so I'll need helping testing it.
 
 Jay
 
 
  Kind regards,
  Sean
 
  --
  You received this message because you are subscribed to the Google Groups 
  Racket Users group.
  To unsubscribe from this group and stop receiving emails from it, send an 
  email to racket-users+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.
 
 
 
 -- 
 Jay McCarthy
 http://jeapostrophe.github.io
 
Wherefore, be not weary in well-doing,
   for ye are laying the foundation of a great work.
 And out of small things proceedeth that which is great.
   - DC 64:33

Hi Jay,

Thanks for that, yes I think you are right. I have just installed squid at home 
which also supports http tunnelling. I'll see how I get on and post my results 
- whether they be good or bad!

It would be really good to at least get an example on the wiki for others to 
build from, as I suspect a lot of corporate networks are behind proxies and 
this would be problematic in using Racket to make calls to REST APIs etc which 
my job at least requires a lot of.

Kind regards,
Sean

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] HTTPS connection through proxy (CONNECT HTTP Method)

2015-08-12 Thread Jay McCarthy
On Tue, Aug 11, 2015 at 10:24 AM, Sean Kemplay sean.kemp...@gmail.com wrote:
 Hi All,

 Sending an http request through our corporate proxy works as follows for http 
 requests -

 (define-values (x y z)
   (http-sendrecv 10.0.0.200 http://www.example.com;
  #:port 8080
  #:headers '(
  Proxy-Authorization: Basic 
 base64encodedcredentials
  Proxy-Connections: keep-alive
  )
  #:ssl? #f
  #:method GET))

 However fails for HTTPS requests (as expected).

 What I need to do is make a request like the above using the #:method 
 CONNECT and then make a secondary request through a returned connection.

 Does anyone know how I would go about doing that in Racket?

http-sendrecv combines calls to http-conn-open, http-conn-send!,
http-conn-recv!, then http-conn-close!. I suspect that you just need
to break up that one big call into a few calls like open, send, recv,
send, recv, close. I'd be happy to work on it with you, but I don't
have such a proxy on hand, so I'll need helping testing it.

Jay


 Kind regards,
 Sean

 --
 You received this message because you are subscribed to the Google Groups 
 Racket Users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
Jay McCarthy
http://jeapostrophe.github.io

   Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great.
  - DC 64:33

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.