Sean Leather <leat...@cs.uu.nl> writes:

> We have run into an issue that it seems other people have already
> found but has apparently not been resolved, yet. It manifests as with
> the error "HTTP request failed with: Unsupported socket". The problem
> is described in two places with different workarounds.
>
>   http://code.google.com/p/happstack/issues/detail?id=88
>   http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0
>
> One workaround is to rewrite part of the network package, and the
> other is to downgrade the package. It could be the case that the
> rewrite came from the older version, though I'm not sure.
>
> I'm curious if it is possible to fix this, either in Happstack or the
> network package, once and for all. The workarounds are rather painful
> when so many things depend on the network package.

The following patch to happstack works for me:

Mon May  4 10:35:54 EDT 2009  Gregory Collins <g...@gregorycollins.net>
  * Local fix: make networking work
  Ignore-this: f46cdf40b26ac1ca72e50b05c772c259
diff -rN -u old-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs new-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs
--- old-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs	2009-10-08 10:34:22.000000000 -0400
+++ new-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs	2009-10-08 10:34:22.000000000 -0400
@@ -24,29 +24,11 @@
   (sock', addr) <- S.accept sock
   h <- S.socketToHandle sock' ReadWriteMode
   (N.PortNumber p) <- N.socketPort sock'
-  
-  let peer = $(if supportsIPv6
-                 then
-                 return $ CaseE (VarE (mkName "addr")) 
-                            [Match 
-                             (ConP (mkName "S.SockAddrInet") 
-                              [WildP,VarP (mkName "ha")]) 
-                             (NormalB (AppE (VarE (mkName "showHostAddress")) 
-                                       (VarE (mkName "ha")))) []
-                            ,Match (ConP (mkName "S.SockAddrInet6") [WildP,WildP,VarP (mkName "ha"),WildP])
-                             (NormalB (AppE (VarE (mkName "showHostAddress6")) (VarE (mkName "ha")))) []
-                            ,Match WildP (NormalB (AppE (VarE (mkName "error")) (LitE (StringL "Unsupported socket")))) []]
-                 -- the above mess is the equivalent of this: 
-                 {-[| case addr of
-                       (S.SockAddrInet _ ha)      -> showHostAddress ha
-                       (S.SockAddrInet6 _ _ ha _) -> showHostAddress6 ha
-                       _                          -> error "Unsupported socket"
-                   |]-}
-                 else
-                 [| case addr of
-                      (S.SockAddrInet _ ha)      -> showHostAddress ha
-                      _                          -> error "Unsupported socket"
-                 |])
-                     
+
+  let peer = case addr of
+               (S.SockAddrInet _ ha)      -> showHostAddress ha
+               (S.SockAddrInet6 _ _ ha _) -> showHostAddress6 ha
+               _                          -> error "Unsupported socket"
+
   return (h, peer, p)
 
diff -rN -u old-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs new-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs
--- old-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs	2009-10-08 10:34:22.000000000 -0400
+++ new-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs	2009-10-08 10:34:22.000000000 -0400
@@ -8,9 +8,4 @@
 
 -- find out at compile time if the SockAddr6 / HostAddress6 constructors are available
 supportsIPv6 :: Bool
-supportsIPv6 = $(let c = "Network.Socket.SockAddrInet6"; d = ''SockAddr in
-                 do TyConI (DataD _ _ _ cs _) <- reify d
-                    if isJust (find (\(NormalC n _) -> show n == c) cs)
-                       then [| True |]
-                       else [| False |] )
-                       
+supportsIPv6 = True

G.
-- 
Gregory Collins <g...@gregorycollins.net>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to