Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. network.curl wondering about the relationship between
CurlCookieJar and CurlCookieFile (Michael Litchard)
2. Overlapping Instances (John Smith)
3. Re: Overlapping Instances (Markus L?ll)
4. Re: Overlapping Instances (John Smith)
----------------------------------------------------------------------
Message: 1
Date: Sat, 23 Oct 2010 14:35:46 -0700
From: Michael Litchard <[email protected]>
Subject: [Haskell-beginners] network.curl wondering about the
relationship between CurlCookieJar and CurlCookieFile
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
The problem is, while doing an HTTP(S) conversation between my client,
and the application server, there's a point where the server delivers
a a few new cookies. Now, I am able to get the initial cookies for the
jar, but I don't get the new cookies when I am supposed to. I started
looking at the various constructors offered by Network.Curl and came
across CurlCookieFile. I'm wondering if this is the missing piece. If
I need it, how does it fit in with CurlCookieJar?
I'm including my current code, and the headers I'm getting. I'll note
where the cookies are supposed to come in but don't.
Any clues on how to troubleshoot, and some info on CurlCookieFile
would be greatly appreciated.
> import Network.Curl
> import System (getArgs)
> import Text.Regex.Posix
> -- | Standard options used for all requests. Uncomment the @CurlVerbose@
> -- option for lots of info on STDOUT.
> opts = [CurlCookieJar "cookies" , CurlVerbose True, CurlFollowLocation True]
> -- | Additional options to simulate submitting the login form.
> loginOptions user pass =
> method_POST ++ [CurlPostFields [ "login=" ++ user, "password=" ++ pass ]]
> main = withCurlDo $ do
> -- Get username and password from command line arguments (will cause
> -- pattern match failure if incorrect number of args provided).
> [user, pass] <- getArgs
> -- Initialize curl instance.
> curl <- initialize
> setopts curl opts
> -- GET initial request
> r <- do_curl_ curl ("https://172.16.1.18/showLogon.do") method_GET
> :: IO CurlResponse
> -- POST request to login.
> r <- do_curl_ curl "https://172.16.1.18/default/showLogon.do" (loginOptions
> user pass)
> :: IO CurlResponse
> if respCurlCode r /= CurlOK || respStatus r /= 200
> then error $ "Failed to log in: "
> ++ show (respCurlCode r) ++ " -- " ++ respStatusLine r
> else do
> -- POST request showFlashCheck.do
> r <- do_curl_ curl ("https://172.16.1.18/showFlashCheck.do") method_GET
> :: IO CurlResponse
> if respCurlCode r /= CurlOK || respStatus r /= 200
> then error $ "Failed at showFlashCheck.do: "
> ++ show (respCurlCode r) ++ " -- " ++ respStatusLine r
> else do
> -- GET request
> r <- do_curl_ curl
> ("https://172.16.1.18/logon.do?flashVersion=9.0.100") method_GET --- right
> here, the server should respond with more cookies
> :: IO CurlResponse
> if respCurlCode r /= CurlOK || respStatus r /= 200
> then error $ "Failed at login.do?flashVersion=10.0"
> ++ show (respCurlCode r) ++ " -- " ++ respStatusLine r
> else do
> -- go go gadget webForwards!
> r <- do_curl_ curl
> ("https://172.16.1.18/launchWebForward.do?resourceId=4&policy=0&returnTo=%2FshowWebForwards.do")
> method_GET
> :: IO CurlResponse
> if respCurlCode r /= CurlOK || respStatus r /= 200
> then error $ "Failed at Web Foward"
> ++ show (respCurlCode r) ++ " -- " ++
> respStatusLine r
> else putStrLn $ respBody r
Headers ....> GET /showLogon.do HTTP/1.1
Host: 172.16.1.18
Accept: */*
< HTTP/1.1 200 OK
< Date: Sat, 23 Oct 2010 21:32:09 GMT
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
* Added cookie SSLX_SSESHID="5oskk7cts6epk" for domain 172.16.1.18,
path /, expire 0
< Set-Cookie: SSLX_SSESHID=5oskk7cts6epk;Path=/
* Added cookie
lbTrack="BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------"
for domain 172.16.1.18, path /, exp
ire 1287870429
< Set-Cookie:
lbTrack=BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------;Path=/;Expires=Sat,
23-Oct-10 21:47:09
GMT;Secure
< Content-Type: text/html;charset=UTF-8
< Pragma: no-cache
< Cache-Control: no-cache
< Transfer-Encoding: chunked
<
* Connection #0 to host 172.16.1.18 left intact
* Re-using existing connection! (#0) with host 172.16.1.18
* Connected to 172.16.1.18 (172.16.1.18) port 443 (#0)
> POST /default/showLogon.do HTTP/1.1
Host: 172.16.1.18
Accept: */*
Cookie: lbTrack=BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------;
SSLX_SSESHID=5oskk7cts6epk
Content-Length: 32
Content-Type: application/x-www-form-urlencoded
< HTTP/1.1 200 OK
< Date: Sat, 23 Oct 2010 21:32:09 GMT
< Content-Type: text/html;charset=UTF-8
< Pragma: no-cache
< Cache-Control: no-cache
< Transfer-Encoding: chunked
<
* Connection #0 to host 172.16.1.18 left intact
* Re-using existing connection! (#0) with host 172.16.1.18
* Connected to 172.16.1.18 (172.16.1.18) port 443 (#0)
> GET /showFlashCheck.do HTTP/1.1
Host: 172.16.1.18
Accept: */*
Cookie: lbTrack=BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------;
SSLX_SSESHID=5oskk7cts6epk
< HTTP/1.1 200 OK
< Date: Sat, 23 Oct 2010 21:32:09 GMT
< Content-Type: text/html;charset=UTF-8
< Transfer-Encoding: chunked
<
* Connection #0 to host 172.16.1.18 left intact
* Re-using existing connection! (#0) with host 172.16.1.18
* Connected to 172.16.1.18 (172.16.1.18) port 443 (#0)
> GET /logon.do?flashVersion=9.0.100 HTTP/1.1 <------ right here
> is where it falls down. No cookies for me.
Host: 172.16.1.18
Accept: */*
Cookie: lbTrack=BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------;
SSLX_SSESHID=5oskk7cts6epk
< HTTP/1.1 302 Moved Temporarily
< Date: Sat, 23 Oct 2010 21:32:09 GMT
< Content-Type: text/html
< Location: https://172.16.1.18/default/showLogon.do?msgId=0
< Content-Length: 0
<
* Connection #0 to host 172.16.1.18 left intact
* Issue another request to this URL:
'https://172.16.1.18/default/showLogon.do?msgId=0'
* Re-using existing connection! (#0) with host 172.16.1.18
* Connected to 172.16.1.18 (172.16.1.18) port 443 (#0)
> GET /default/showLogon.do?msgId=0 HTTP/1.1
Host: 172.16.1.18
Accept: */*
Cookie: lbTrack=BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------;
SSLX_SSESHID=5oskk7cts6epk
< HTTP/1.1 200 OK
< Date: Sat, 23 Oct 2010 21:32:09 GMT
< Content-Type: text/html;charset=UTF-8
< Pragma: no-cache
< Cache-Control: no-cache
< Transfer-Encoding: chunked
<
* Connection #0 to host 172.16.1.18 left intact
* Re-using existing connection! (#0) with host 172.16.1.18
* Connected to 172.16.1.18 (172.16.1.18) port 443 (#0)
> GET /launchWebForward.do?resourceId=4&policy=0&returnTo=%2FshowWebForwards.do
> HTTP/1.1
Host: 172.16.1.18
Accept: */*
Cookie: lbTrack=BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------;
SSLX_SSESHID=5oskk7cts6epk
< HTTP/1.1 302 Moved Temporarily
< Date: Sat, 23 Oct 2010 21:32:09 GMT
< Content-Type: text/html
< Location: https://172.16.1.18/default/showLogon.do
< Content-Length: 0
<
* Connection #0 to host 172.16.1.18 left intact
* Issue another request to this URL: 'https://172.16.1.18/default/showLogon.do'
* Re-using existing connection! (#0) with host 172.16.1.18
* Connected to 172.16.1.18 (172.16.1.18) port 443 (#0)
> GET /default/showLogon.do HTTP/1.1
Host: 172.16.1.18
Accept: */*
Cookie: lbTrack=BFQZHBGQBMURVJWIMWXTPIGSYYPCRCRTLSJUZBMJYZCQTTXNSVPH--------;
SSLX_SSESHID=5oskk7cts6epk
< HTTP/1.1 200 OK
< Date: Sat, 23 Oct 2010 21:32:09 GMT
< Content-Type: text/html;charset=UTF-8
< Pragma: no-cache
< Cache-Control: no-cache
< Transfer-Encoding: chunked
<
* Connection #0 to host 172.16.1.18 left intact
* Closing connection #0
------------------------------
Message: 2
Date: Sun, 24 Oct 2010 15:54:19 +0200
From: John Smith <[email protected]>
Subject: [Haskell-beginners] Overlapping Instances
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Following is a simplification of some code which I have written. I have an
overlapping Show instance for A, which is
more specific than the general instance for arrays, so I would expect it to be
acceptable as an overlapping instance.
Nevertheless, I get the following compiler error:
Overlapping instances for Show A
arising from a use of `show' at 13:17-22
Matching instances:
instance (Ix a, Show a, Show b) => Show (Array a b)
-- Defined in GHC.Arr
instance [overlap ok] Show A -- Defined at 9:9-14
In the expression: show a
In the definition of `show': show (B a) = show a
In the instance declaration for `Show B'
Compilation failed.
I've tried UndecidableInstances and IncoherentInstances, but they don't seem to
help. What am I doing wrong?
Many thanks in advance for any assistance.
-John
{-# LANGUAGE TypeSynonymInstances, OverlappingInstances #-}
import Data.Array
type A = Array Int Bool
data B = B A
instance Show A where
show a = "foo"
instance Show B where
show (B a) = show a
------------------------------
Message: 3
Date: Sun, 24 Oct 2010 17:37:01 +0300
From: Markus L?ll <[email protected]>
Subject: Re: [Haskell-beginners] Overlapping Instances
To: John Smith <[email protected]>, [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi John,
from what I gather this is because Show instance for "Array a b",
which you are overlapping, is defined in a module without the
OverlappingInstances declaration. Check the last few paragraphs of
this from the GHC's user's guide:
http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/type-class-extensions.html#instance-overlap
Markus Läll
On Sun, Oct 24, 2010 at 4:54 PM, John Smith <[email protected]> wrote:
> Following is a simplification of some code which I have written. I have an
> overlapping Show instance for A, which is more specific than the general
> instance for arrays, so I would expect it to be acceptable as an overlapping
> instance. Nevertheless, I get the following compiler error:
>
> Overlapping instances for Show A
> arising from a use of `show' at 13:17-22
> Matching instances:
> instance (Ix a, Show a, Show b) => Show (Array a b)
> -- Defined in GHC.Arr
> instance [overlap ok] Show A -- Defined at 9:9-14
> In the expression: show a
> In the definition of `show': show (B a) = show a
> In the instance declaration for `Show B'
> Compilation failed.
>
> I've tried UndecidableInstances and IncoherentInstances, but they don't seem
> to help. What am I doing wrong?
>
> Many thanks in advance for any assistance.
>
> -John
>
> {-# LANGUAGE TypeSynonymInstances, OverlappingInstances #-}
>
> import Data.Array
>
> type A = Array Int Bool
>
> data B = B A
>
> instance Show A where
> show a = "foo"
>
> instance Show B where
> show (B a) = show a
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 4
Date: Sun, 24 Oct 2010 17:48:34 +0200
From: John Smith <[email protected]>
Subject: [Haskell-beginners] Re: Overlapping Instances
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Thank you very much for explaining the problem. (I'd read the documentation,
but didn't understand where I'd gone wrong.)
I found a ticket to fix this at http://hackage.haskell.org/trac/ghc/ticket/3877
On 24/10/2010 16:37, Markus Läll wrote:
> Hi John,
>
> from what I gather this is because Show instance for "Array a b",
> which you are overlapping, is defined in a module without the
> OverlappingInstances declaration. Check the last few paragraphs of
> this from the GHC's user's guide:
>
> http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/type-class-extensions.html#instance-overlap
>
>
> Markus Läll
>
> On Sun, Oct 24, 2010 at 4:54 PM, John Smith<[email protected]> wrote:
>> Following is a simplification of some code which I have written. I have an
>> overlapping Show instance for A, which is more specific than the general
>> instance for arrays, so I would expect it to be acceptable as an overlapping
>> instance. Nevertheless, I get the following compiler error:
>>
>> Overlapping instances for Show A
>> arising from a use of `show' at 13:17-22
>> Matching instances:
>> instance (Ix a, Show a, Show b) => Show (Array a b)
>> -- Defined in GHC.Arr
>> instance [overlap ok] Show A -- Defined at 9:9-14
>> In the expression: show a
>> In the definition of `show': show (B a) = show a
>> In the instance declaration for `Show B'
>> Compilation failed.
>>
>> I've tried UndecidableInstances and IncoherentInstances, but they don't seem
>> to help. What am I doing wrong?
>>
>> Many thanks in advance for any assistance.
>>
>> -John
>>
>> {-# LANGUAGE TypeSynonymInstances, OverlappingInstances #-}
>>
>> import Data.Array
>>
>> type A = Array Int Bool
>>
>> data B = B A
>>
>> instance Show A where
>> show a = "foo"
>>
>> instance Show B where
>> show (B a) = show a
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 28, Issue 36
*****************************************