darcs

Patch 573 Using proxy without libcurl

Title Using proxy without libcurl
Superseder Nosy List chris
Related Issues
Status accepted Assigned To
Milestone

Created on 2011-04-01.14:12:01 by chris, last changed 2011-06-04.15:50:47 by mornfall. Tracked on DarcsWatch.

Files
File name Status Uploaded Type Edit Remove
using-proxy-without-libcurl.dpatch chris, 2011-04-01.14:12:01 text/x-darcs-patch
See mailing list archives for discussion on individual patches.
Messages
msg13852 (view) Author: chris Date: 2011-04-01.14:12:01
1 patch for repository http://darcs.net:

Thu Mar 31 20:12:19 CEST 2011  Chris Trompette <chris@trompette.name>
  * Using proxy without libcurl
Attachments
msg13904 (view) Author: darcswatch Date: 2011-04-06.20:15:30
This patch bundle (with 1 patches) was just applied to the repository http://darcs.net/screened.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_screened.html#bundle-e7a64a4fffc4039f3467d078975669903ab187b5
msg13993 (view) Author: darcswatch Date: 2011-05-08.09:55:27
This patch bundle (with 1 patches) was just applied to the repository http://darcs.net/.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-e7a64a4fffc4039f3467d078975669903ab187b5
msg14465 (view) Author: galbolle Date: 2011-05-26.13:15:43
Thanks, looks ready for applying. Have you tested on windows?

Using proxy without libcurl
---------------------------
Chris Trompette <chris@trompette.name>**20110331181219

hunk ./src/HTTP.hs 9
[…]

hunk ./src/HTTP.hs 11
> +import Network.Browser ( browse, request, setCheckForProxy,
setErrHandler, setOutHandler )
>  import Network.URI

We now need Network.Browser, in http.

hunk ./src/HTTP.hs 13
[…]

hunk ./src/HTTP.hs 48
>  fetchUrl url = case parseURI url of
>      Nothing -> fail $ "Invalid URI: " ++ url
>      Just uri -> do debugMessage $ "Fetching over HTTP:  "++url
> -                   proxy <- getProxy
> -                   when (not $ null proxy) $
> -                     debugFail "No proxy support for HTTP package
yet (try libcurl)!"

ok

> -                   resp <- simpleHTTP $ Request { rqURI = uri,
> -                                                  rqMethod = GET,
> -                                                  rqHeaders = headers,
> -                                                  rqBody = "" }
> +                   resp <- catch (browse $ do
> +                     setCheckForProxy True
> +                     setOutHandler debugMessage
> +                     setErrHandler debugMessage
> +                     request Request { rqURI = uri,
> +                                       rqMethod = GET,
> +                                       rqHeaders = headers,
> +                                       rqBody = "" })
> +                     (\err -> debugFail $ show err)
>                     case resp of

browse is responsible for dealing with the proxy.

hunk ./src/HTTP.hs 58
> -                     Right res@Response { rspCode = (2,0,0) } ->
return (rspBody res)
> -                     Right Response { rspCode = (x,y,z) } ->
> +                     (_, res@Response { rspCode = (2,0,0) }) ->
return (rspBody res)
> +                     (_, Response { rspCode = (x,y,z) }) ->
>                           debugFail $ "HTTP " ++ show x ++ show y ++
show z ++ " error getting " ++ show uri

hunk ./src/HTTP.hs 61
> -                     Left err -> debugFail $ show err
>  
>  postUrl url body mime = case parseURI url of
>      Nothing -> fail $ "Invalid URI: " ++ url

Ok

hunk ./src/HTTP.hs 65
>      Just uri -> do debugMessage $ "Posting to HTTP:  "++url
> -                   proxy <- getProxy
> -                   when (not $ null proxy) $
> -                     debugFail "No proxy support for HTTP package yet
(try libcurl)!"
> -                   resp <- simpleHTTP $ Request { rqURI = uri,
> -                                                  rqMethod = POST,
> -                                                  rqHeaders = headers
++ [Header HdrContentType mime,
> -                                                                    
     Header HdrAccept "text/plain",
> -                                                                    
     Header HdrContentLength
> -                                                                    
                (show $ length body) ],
> -                                                  rqBody = body }
> +                   resp <- catch (browse $ do
> +                     setCheckForProxy True
> +                     setOutHandler debugMessage
> +                     setErrHandler debugMessage
> +                     request Request { rqURI = uri,
> +                                       rqMethod = POST,
> +                                       rqHeaders = headers ++ [Header
HdrContentType mime,
> +                                                               Header
HdrAccept "text/plain",
> +                                                               Header
HdrContentLength
> +                                                                    
   (show $ length body) ],
> +                                       rqBody = body })
> +                     (\err -> debugFail $ show err)
>                     case resp of

hunk ./src/HTTP.hs 78
> -                     Right res@Response { rspCode = (2,y,z) } -> do
> +                     (_, res@Response { rspCode = (2,y,z) }) -> do
>                          putStrLn $ "Success 2" ++ show y ++ show z
>                          putStrLn (rspBody res)
>                          return ()

hunk ./src/HTTP.hs 82
> -                     Right res@Response { rspCode = (x,y,z) } -> do
> +                     (_, res@Response { rspCode = (x,y,z) }) -> do
>                          putStrLn $ rspBody res
>                          debugFail $ "HTTP " ++ show x ++ show y ++
show z ++ " error posting to " ++ show uri

Likewise

hunk ./src/HTTP.hs 85
> -                     Left err -> debugFail $ show err
>  
>  requestedUrl :: IORef (String, FilePath)
>  requestedUrl = unsafePerformIO $ newIORef ("", "")

hunk ./src/HTTP.hs 108
>               return (u, e, ce)
>      where h = return . ioeGetErrorString
>  
> -getProxy :: IO String
> -getProxy =
> -  getEnv "http_proxy"
> -  `catch` \_ -> getEnv "HTTP_PROXY"
> -  `catch` \_ -> return ""
>  #else
>  
>  fetchUrl _ = debugFail "Network.HTTP does not exist"

ok
msg14486 (view) Author: ganesh Date: 2011-06-03.06:32:58
I've been using this on Windows for a bit - no obvious problems, though I 
haven't tested wit a proxy.
msg14488 (view) Author: darcswatch Date: 2011-06-03.06:35:21
This patch bundle (with 1 patches) was just applied to the repository http://darcs.net/reviewed.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-e7a64a4fffc4039f3467d078975669903ab187b5
msg14495 (view) Author: mornfall Date: 2011-06-04.15:50:47
Hi,

Ganesh Sittampalam <bugs@darcs.net> writes:
> I've been using this on Windows for a bit - no obvious problems, though I
> haven't tested wit a proxy.

I think this warrants a HTTP dependency bump:
http://buildbot.darcs.net/builders/6.10.4%20SCREENED%20Vista/builds/0/steps/compile/logs/stdio

Yours,
   Petr


-- 
id' Ash = Ash; id' Dust = Dust; id' _ = undefined
History
Date User Action Args
2011-04-01 14:12:01chriscreate
2011-04-01 14:12:32darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-e7a64a4fffc4039f3467d078975669903ab187b5
2011-04-01 15:07:27chrissetfiles: - unnamed
2011-04-06 20:15:31darcswatchsetmessages: + msg13904
2011-05-08 09:55:27darcswatchsetstatus: needs-review -> accepted
messages: + msg13993
2011-05-09 05:37:23ganeshsetstatus: accepted -> needs-review
2011-05-10 19:05:49darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-e7a64a4fffc4039f3467d078975669903ab187b5 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-e7a64a4fffc4039f3467d078975669903ab187b5
2011-05-26 13:15:44galbollesetstatus: needs-review -> accepted-pending-tests
messages: + msg14465
2011-06-03 06:32:58ganeshsetstatus: accepted-pending-tests -> accepted
messages: + msg14486
2011-06-03 06:35:21darcswatchsetmessages: + msg14488
2011-06-04 15:50:47mornfallsetmessages: + msg14495