| | [Haskell-cafe] Two GET HTTP requests  | 
05-02-10, 06:52 PM
| | | [Haskell-cafe] Two GET HTTP requests Hi everyone,
I'm trying to do a number of successive HTTP requests in one program. Here's what I tried:
Approach 1: I used the 'download' package, which failed to install on OS X. It fails with "error: libio.h: No such file or directory".
Approach 2: I installed the 'download-curl' package, and tried again. This seems to fail on the following example:
> import Network.Curl.Download
>
> main = do x <- openURI "http://haskell.org"
> y <- openURI "http://haskell.org/hoogle"
> return ()
If I put a print statement around the second line of the do-statement it looks like openURI never returns.
Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following:
> simpleHTTP (getRequest "http://haskell.org")
This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
I'm a bit stuck here, I would love to help fix the errors, but don't know what would be the best place to begin. If anyone can point me in the right direction, I will try to patch at least one of these packages.
Thanks,
-chris
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
07-02-10, 04:08 PM
| | | Re: [Haskell-cafe] Two GET HTTP requests Hello,
On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof <chris@eidhof.nl> wrote:
> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following:
>
>> simpleHTTP (getRequest "http://haskell.org")
>
> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
Try reinstall network package with `cabal install --reinstall
--hsc2hs-options="--cflag=-m32 --lflag=-m32"`.
See also: [url]http://hackage.haskell.org/trac/ghc/ticket/3681[/url]
Hope this helps.
--nwn
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
07-02-10, 04:50 PM
| | | Re: [Haskell-cafe] Two GET HTTP requests Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it.
-chris
On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote:
> Hello,
>
> On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof <chris@eidhof.nl> wrote:
>> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following:
>>
>>> simpleHTTP (getRequest "http://haskell.org")
>>
>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
>
> Try reinstall network package with `cabal install --reinstall
> --hsc2hs-options="--cflag=-m32 --lflag=-m32"`.
>
> See also: [url]http://hackage.haskell.org/trac/ghc/ticket/3681[/url]
>
> Hope this helps.
> --nwn
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
07-02-10, 06:12 PM
| | | Re: [Haskell-cafe] Two GET HTTP requests On Fri, Feb 5, 2010 at 5:51 PM, Chris Eidhof <chris@eidhof.nl> wrote:
> Approach 2: I installed the 'download-curl' package, and tried again. This seems to fail on the following example:
>
>> import Network.Curl.Download
>>
>> main = do x <- openURI "http://haskell.org"
>> * * * * * y <- openURI "http://haskell.org/hoogle"
>> * * * * * return ()
>
> If I put a print statement around the second line of the do-statement it looks like openURI never returns.
>
I think you're supposed to use withCurlDo:
[url]http://hackage.haskell.org/packages/archive/curl/latest/doc/html/Network-Curl.html#v%3AwithCurlDo[/url]
with the curl library. Could be wrong about that, haven't tried it myself.
> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following:
>
>> simpleHTTP (getRequest "http://haskell.org")
>
> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
"Bus error" is a message generated by the operating system. On OS X,
it can mean a null dereference, which is very unusual. I'm not sure
how you'd debug it either - the most common cause when you're talking
about C applications is programmer error, but Network.HTTP is
specifically designed to be pure Haskell, and it's not easy to induce
a null dereference from Haskell.
> I'm a bit stuck here, I would love to help fix the errors, but don't know what would be the best place to begin. If anyone can point me in the right direction, I will try to patch at least one of these packages.
I don't think anyone would blame you if you didn't manage it, none of
those are particularly friendly errors.
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
07-02-10, 07:53 PM
| | | Re: [Haskell-cafe] Two GET HTTP requests On Sun, Feb 07, 2010 at 05:12:23PM +0000, Ben Millwood wrote:
> > This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
> "Bus error" is a message generated by the operating system. On OS X,
> it can mean a null dereference, which is very unusual.
You did not mention whether the machine running your OS X was a PowerPC
or an "Intel" machine.
On non-x86 platforms, a bus error is usually caused by misaligned memory
accesses. Unlike the x86 which silently and expensively fixes any
misaligned accesses, sane processors kick and scream, resulting in a bus
error.
Such things tend to happen quite often when development of a software
mainly takes place on x86 family chips, and are revealed when some poor
soul on an UltraSparcIII tries to run them.
--
Lars Viklund | [email]zao@acc.umu.se[/email]
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
08-02-10, 10:33 AM
| | | Re: [Haskell-cafe] Two GET HTTP requests On 7 feb 2010, at 19:52, Lars Viklund wrote:
> On Sun, Feb 07, 2010 at 05:12:23PM +0000, Ben Millwood wrote:
>>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
>> "Bus error" is a message generated by the operating system. On OS X,
>> it can mean a null dereference, which is very unusual.
>
> You did not mention whether the machine running your OS X was a PowerPC
> or an "Intel" machine.
>
> On non-x86 platforms, a bus error is usually caused by misaligned memory
> accesses. Unlike the x86 which silently and expensively fixes any
> misaligned accesses, sane processors kick and scream, resulting in a bus
> error.
>
> Such things tend to happen quite often when development of a software
> mainly takes place on x86 family chips, and are revealed when some poor
> soul on an UltraSparcIII tries to run them.
I'm on X86, Snow Leopard. I'm running GHC 6.10.2.
-chris_____________________________________________ __
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
08-02-10, 10:35 AM
| | | Re: [Haskell-cafe] Two GET HTTP requests I should add that I was able to work around the issue by using Michael Snoyman's http-wget [1] package. It uses the command-line version of wget, which does work on my machine.
-chris
[1]: [url]http://hackage.haskell.org/package/http-wget[/url]
On 7 feb 2010, at 16:50, Chris Eidhof wrote:
> Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it.
>
> -chris
>
> On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote:
>
>> Hello,
>>
>> On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof <chris@eidhof.nl> wrote:
>>> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following:
>>>
>>>> simpleHTTP (getRequest "http://haskell.org")
>>>
>>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
>>
>> Try reinstall network package with `cabal install --reinstall
>> --hsc2hs-options="--cflag=-m32 --lflag=-m32"`.
>>
>> See also: [url]http://hackage.haskell.org/trac/ghc/ticket/3681[/url]
>>
>> Hope this helps.
>> --nwn
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email]Haskell-Cafe@haskell.org[/email]
> [url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url]
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
09-02-10, 06:42 AM
| | | Re: [Haskell-cafe] Two GET HTTP requests Try to reinstall HTTP package also. I think your HTTP package is still
linked with old broken network package.
HTTP depends on network. And network is a binding for network API of
OS. These API is for C-language. When ghc builds such binding
packages, It runs gcc for some purpose. gcc thinks you need 64bit
binary (from SL, I believe.) and works for 64bit environment. But ghc
on Mac can only build 32bit binaries. So it causes the problem.
You can check if network package was correctly built by running this.
This takes a host name, and gets the root document of the host via
HTTP using a socket. Build and try `./this_program haskell.org`
import Network.Socket
import System.IO
import System.Environment
getAddr :: HostName -> IO AddrInfo
getAddr host = head `fmap`
(getAddrInfo (Just defaultHints { addrSocketType = Stream })
(Just host)
(Just "http"))
connected :: HostName -> IO Socket
connected host = do
addrinfo <- getAddr host
sock <- socket (addrFamily addrinfo)
(addrSocketType addrinfo)
(addrProtocol addrinfo)
connect sock (addrAddress addrinfo)
return sock
httpGet :: HostName -> IO String
httpGet host = do
h <- flip socketToHandle ReadWriteMode =<< connected host
hSetBuffering h NoBuffering
hPutStr h "GET / HTTP/1.0\r\n\r\n"
hGetContents h
main = fmap head getArgs >>= httpGet >>= putStr
I should have mentioned them in my last mail. Sorry.
By the way, ghc-6.12 on Mac still can not build 64bit binaries. So
upgrading ghc won't solve it.
--nwn
On Mon, Feb 8, 2010 at 12:50 AM, Chris Eidhof <chris@eidhof.nl> wrote:
> Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it.
>
> -chris
>
> On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote:
>
>> Hello,
>>
>> On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof <chris@eidhof.nl> wrote:
>>> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following:
>>>
>>>> simpleHTTP (getRequest "http://haskell.org")
>>>
>>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
>>
>> Try reinstall network package with `cabal install --reinstall
>> --hsc2hs-options="--cflag=-m32 --lflag=-m32"`.
>>
>> See also: [url]http://hackage.haskell.org/trac/ghc/ticket/3681[/url]
>>
>> Hope this helps.
>> --nwn
>
>
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
10-02-10, 10:53 AM
| | | Re: [Haskell-cafe] Two GET HTTP requests Hi nwn,
I had the following error:
Run: Network/Socket/Internal.hsc  298,2)-(314,60): Non-exhaustive patterns in case. The code for those lines look like this:
> peekSockAddr p = do
> family <- (#peek struct sockaddr, sa_family) p
> case family :: CSaFamily of
> #if defined(DOMAIN_SOCKET_SUPPORT)
> (#const AF_UNIX) -> do
> str <- peekCString ((#ptr struct sockaddr_un, sun_path) p)
> return (SockAddrUnix str)
> #endif
> (#const AF_INET) -> do
> addr <- (#peek struct sockaddr_in, sin_addr) p
> port <- (#peek struct sockaddr_in, sin_port) p
> return (SockAddrInet (PortNum port) addr)
> #if defined(IPV6_SOCKET_SUPPORT)
> (#const AF_INET6) -> do
> port <- (#peek struct sockaddr_in6, sin6_port) p
> flow <- (#peek struct sockaddr_in6, sin6_flowinfo) p
> addr <- (#peek struct sockaddr_in6, sin6_addr) p
> scope <- (#peek struct sockaddr_in6, sin6_scope_id) p
> return (SockAddrInet6 (PortNum port) flow addr scope)
> #endif
Thanks for all your help. I'll first upgrade to a new GHC and then try again.
-chris
On 9 feb 2010, at 06:41, Yusaku Hashimoto wrote:
> Try to reinstall HTTP package also. I think your HTTP package is still
> linked with old broken network package.
>
> HTTP depends on network. And network is a binding for network API of
> OS. These API is for C-language. When ghc builds such binding
> packages, It runs gcc for some purpose. gcc thinks you need 64bit
> binary (from SL, I believe.) and works for 64bit environment. But ghc
> on Mac can only build 32bit binaries. So it causes the problem.
>
> You can check if network package was correctly built by running this.
> This takes a host name, and gets the root document of the host via
> HTTP using a socket. Build and try `./this_program haskell.org`
>
> import Network.Socket
> import System.IO
> import System.Environment
>
> getAddr :: HostName -> IO AddrInfo
> getAddr host = head `fmap`
> (getAddrInfo (Just defaultHints { addrSocketType = Stream })
> (Just host)
> (Just "http"))
>
> connected :: HostName -> IO Socket
> connected host = do
> addrinfo <- getAddr host
> sock <- socket (addrFamily addrinfo)
> (addrSocketType addrinfo)
> (addrProtocol addrinfo)
> connect sock (addrAddress addrinfo)
> return sock
>
> httpGet :: HostName -> IO String
> httpGet host = do
> h <- flip socketToHandle ReadWriteMode =<< connected host
> hSetBuffering h NoBuffering
> hPutStr h "GET / HTTP/1.0\r\n\r\n"
> hGetContents h
>
> main = fmap head getArgs >>= httpGet >>= putStr
>
> I should have mentioned them in my last mail. Sorry.
>
> By the way, ghc-6.12 on Mac still can not build 64bit binaries. So
> upgrading ghc won't solve it.
>
> --nwn
>
> On Mon, Feb 8, 2010 at 12:50 AM, Chris Eidhof <chris@eidhof.nl> wrote:
>> Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it.
>>
>> -chris
>>
>> On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote:
>>
>>> Hello,
>>>
>>> On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof <chris@eidhof.nl> wrote:
>>>> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following:
>>>>
>>>>> simpleHTTP (getRequest "http://haskell.org")
>>>>
>>>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this.
>>>
>>> Try reinstall network package with `cabal install --reinstall
>>> --hsc2hs-options="--cflag=-m32 --lflag=-m32"`.
>>>
>>> See also: [url]http://hackage.haskell.org/trac/ghc/ticket/3681[/url]
>>>
>>> Hope this helps.
>>> --nwn
>>
>>
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] |  | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT +1. The time now is 06:11 PM.
Powered by vBulletin® Version 3.6.8 Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 | |