Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Solution: Proxy-Authentication Bug in REBOL/View-Panel

From: jsc:dataheaven at: 26-Sep-2000 21:55

I earlier posted a quick-hack to allow to use the REB-Access through Proxies/Firewalls. But there was another Bug in the patched read-net function that prevents read-net to work through Proxies that want a username and a password for authentication. This is another quick hack to solve this: read-net: func [ {Read a file from the net (web). Update progress bar. Allow abort.} host-name path /progress callfunc port-hand /local port buffer hdr-brk get-data body time data errc size wholepath ][ if error? try [ port: open/direct/binary/no-wait [scheme: 'tcp host: system/schemes/default/proxy/host port-id: system/schemes/default/proxy/port-id] wholepath: rejoin ["http://" host-name path] ] [return none] insert port rejoin [ "GET " wholepath " HTTP/1.0" crlf "User-Agent: REBOL/View " system/version crlf "Accept: */*" crlf "Host: " host-name crlf "Proxy-Authorization: " join "Basic " enbase join system/schemes/default/proxy/user [#":" system/schemes/default/proxy/pass] crlf "Connection: close" crlf crlf ] buffer: make binary! 4000 hdr-brk: rejoin [crlf crlf] size: none errc: 900 get-data: func [port] [ if none? data: copy port [close port return 'break] append buffer data if all [not size body: find/tail buffer hdr-brk] [ parse buffer [ "HTTP" thru " " copy errc [to " " | to newline] (errc: load/all errc) thru "Content-length:" copy size to newline] if errc > 299 [close port return 'break] size: either size [to-integer trim size] [10000] remove/part buffer body buffer: make binary! size + 32 append buffer head body ] if all [size progress] [callfunc size length? buffer] ] dispatch append copy any [port-hand []] [ port :get-data 30 [print "TIMEOUT***********" close port 'break] ] if errc < 300 [return buffer] ] IMPORTANT: If you want to use this function you have to set your default-proxy "host" , port-id , "user" and "pass" parameters. If you do not need proxy-authentication you have to use the function of my earlier post. Experienced readers will easily find the lines I've changed in comparison to the old function. But let's face it - this is an ugly hack, that makes that read-net doesn't work without a proxy (and now authentication) anymore. What someone (at RT?) should do now is to ad the proper tests if a Proxy should be used and then does the connection and request either the old direct way or the new "proxied" way. Heres an outline: 1) Test if a default-proxy is set 2) Test if requested hostname is in he "bypass" default-proxy settings 3) if 1) is false or 2) is true use the old code otherwise use the default-proxy for connection, the whole url in the request and obviously the username and password for proxy-authorization I've think I'll send a feedback to RT and hope they will finally fix this in a nice way. Jochen