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. Re:  IO String inside a CmdArgs data (Daniel Fischer)
   2.  Network.Curl.Opts problem (may show up on        haskell-cafe as
      well) (Michael Litchard)
   3. Re:  Network.Curl.Opts problem (may show up on haskell-cafe
      as well) (Patrick LeBoutillier)
   4. Re:  IO String inside a CmdArgs data (Kamil Stachowski)


----------------------------------------------------------------------

Message: 1
Date: Fri, 14 Jan 2011 23:40:29 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] IO String inside a CmdArgs data
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="utf-8"

On Friday 14 January 2011 21:45:49, Kamil Stachowski wrote:
> It is funny, indeed :)
>
> In fact, I am after all going to get unsafe because what Daniel Fischer
> wrote above worked perfectly until I wanted to add annotations to ftConf
> (the "&= summary" bit in http://community.haskell.org/~ndm/cmdargs/).
> The only way I can go around the errors I get is precisely unsafe, so
> ah, you only live once ;)

Well, you could try

setTime :: FuzzyTimeConf -> IO FuzzyTimeConf
setTime ftc = do
  now <- getClockTime
  return $ ftc{ time = convert now }

-- put annotations here
defaultFuzzyTimeConf = FuzzyTimeConf { ... }

main = do
  realFTConf <- setTime defaultTimeConf
  print =<< cmdArgs realFTConf

I haven't looked at cmdargs, so I've no idea whether that'll work, but it 
may be worth a try.



------------------------------

Message: 2
Date: Fri, 14 Jan 2011 17:12:13 -0800
From: Michael Litchard <[email protected]>
Subject: [Haskell-beginners] Network.Curl.Opts problem (may show up on
        haskell-cafe as well)
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Reposting this, as it seems my Haskell Cafe posts for the past few days
aren't making it to the list.


I'm having trouble passing header strings properly, and I'd like some advice
on how to proceed. Below is a capture of what is being sent, versus what I
am trying to send. I won't include all code, only what I think is necessary.
If I have omitted something important, please let me know. How could I
discover what the cause of the discrepancy is?
Thanks again for any feedback.


Here's a snippet from the header, what is being sent.

> GET
/resourceList.do?form=webForwardsForm&readOnly=false&policyLaunching=true&resourcePrefix=webForwards&path=%2FshowWebForwards.do&messageResourcesKey=webForwards&actionPath=%2FresourceList.do
HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: 172.16.1.18
Accept: */*
Accept-Encoding: gzip,deflate
Referer: https://172.16.1.18/showWebForwards.do
Cookie: domainLogonTicket=SLXa10225c6e8389b3eb181e3df5dcf08de;
logonTicket=SLXa10225c6e8389b3eb181e3df5dcf08de;
lbTrack=OAIAGHMWQDOLYYTJEXQHXBYPXVALXNREKIHAYYRZSOGYJLUYNNCJ--------;
SSLX_SSESHID=bvgx4mggmy6v

^ compare this to CurlHttpHeaders

Here's the part of the source I think is relevant

> launch :: String -> String -> IO (Either String String)
> launch user pass = do
>  -- Initialize Curl
>   curl <- initCurl

>   -- Sequence of steps
>   let steps = do
>       curlResp curl urlInitial method_GET
>       curlResp curl urlLogin $ loginOpts user pass
>       curlResp curl urlFlash1 method_GET
>       curlResp curl urlFlash2 method_GET
>       curlResp curl urlGetResource resourceOpts    <---- here's where the
problem is revealed

>   runErrorT steps
> main :: IO ()
> main = do
>   -- username and password
>   user:pass:_ <- getArgs

>   -- Launch webpage
>   resp <- launch user pass

>   -- Response comes as Either String String
>   -- You have to handle each case
>   case resp of
>     Left  err  -> print err
>     Right body -> putStrLn body



> resourceOpts :: [CurlOption]
> resourceOpts =
>   [ CurlHttpHeaders
>     [ "Accept  text/javascript, text/html, application/xml, text/xml, */*"
>     , "Accept-Language en-us,en;q=0.5"
>     , "Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7"
>     , "Keep-Alive      115"
>     , "Connection      keep-alive"
>     , "X-Requested-With        XMLHttpRequest"
>     , "X-Prototype-Version     1.6.0.3"
>     ]
>     , CurlEncoding "gzip,deflate"
>     , CurlReferer "https://172.16.1.18/showWebForwards.do";
>   ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110114/ca0cb595/attachment-0001.htm>

------------------------------

Message: 3
Date: Fri, 14 Jan 2011 21:24:59 -0500
From: Patrick LeBoutillier <[email protected]>
Subject: Re: [Haskell-beginners] Network.Curl.Opts problem (may show
        up on haskell-cafe as well)
To: Michael Litchard <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Michael,

I don't know much about Curl, but it looks like your HTTP headers are
not formatted correctly ("HEADER_NAME: VALUE"). Maybe you can try
adding colons like this:

CurlHttpHeaders
  [ "Accept: text/javascript, text/html, application/xml, text/xml, */*"
  , "Accept-Language: en-us,en;q=0.5"
  , "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"
  , "Keep-Alive: 115"
  , "Connection: keep-alive"
  , "X-Requested-With: XMLHttpRequest"
  , "X-Prototype-Version: 1.6.0.3"
  ]


Patrick


On Fri, Jan 14, 2011 at 8:12 PM, Michael Litchard <[email protected]> wrote:
> Reposting this, as it seems my Haskell Cafe posts for the past few days
> aren't making it to the list.
>
>
> I'm having trouble passing header strings properly, and I'd like some advice
> on how to proceed. Below is a capture of what is being sent, versus what I
> am trying to send. I won't include all code, only what I think is necessary.
> If I have omitted something important, please let me know. How could I
> discover what the cause of the discrepancy is?
> Thanks again for any feedback.
>
>
> Here's a snippet from the header, what is being sent.
>
>> GET
>> /resourceList.do?form=webForwardsForm&readOnly=false&policyLaunching=true&resourcePrefix=webForwards&path=%2FshowWebForwards.do&messageResourcesKey=webForwards&actionPath=%2FresourceList.do
>> HTTP/1.1
> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
> Host: 172.16.1.18
> Accept: */*
> Accept-Encoding: gzip,deflate
> Referer: https://172.16.1.18/showWebForwards.do
> Cookie: domainLogonTicket=SLXa10225c6e8389b3eb181e3df5dcf08de;
> logonTicket=SLXa10225c6e8389b3eb181e3df5dcf08de;
> lbTrack=OAIAGHMWQDOLYYTJEXQHXBYPXVALXNREKIHAYYRZSOGYJLUYNNCJ--------;
> SSLX_SSESHID=bvgx4mggmy6v
>
> ^ compare this to CurlHttpHeaders
>
> Here's the part of the source I think is relevant
>
>> launch :: String -> String -> IO (Either String String)
>> launch user pass = do
>>? -- Initialize Curl
>>?? curl <- initCurl
>
>>?? -- Sequence of steps
>>?? let steps = do
>>?????? curlResp curl urlInitial method_GET
>>?????? curlResp curl urlLogin $ loginOpts user pass
>>?????? curlResp curl urlFlash1 method_GET
>>?????? curlResp curl urlFlash2 method_GET
>>?????? curlResp curl urlGetResource resourceOpts??? <---- here's where the
>> problem is revealed
>
>>?? runErrorT steps
>> main :: IO ()
>> main = do
>>?? -- username and password
>>?? user:pass:_ <- getArgs
>
>>?? -- Launch webpage
>>?? resp <- launch user pass
>
>>?? -- Response comes as Either String String
>>?? -- You have to handle each case
>>?? case resp of
>>???? Left? err? -> print err
>>???? Right body -> putStrLn body
>
>
>
>> resourceOpts :: [CurlOption]
>> resourceOpts =
>>?? [ CurlHttpHeaders
>>???? [ "Accept? text/javascript, text/html, application/xml, text/xml, */*"
>>???? , "Accept-Language en-us,en;q=0.5"
>>???? , "Accept-Charset? ISO-8859-1,utf-8;q=0.7,*;q=0.7"
>>???? , "Keep-Alive????? 115"
>>???? , "Connection????? keep-alive"
>>???? , "X-Requested-With??????? XMLHttpRequest"
>>???? , "X-Prototype-Version???? 1.6.0.3"
>>???? ]
>>???? , CurlEncoding "gzip,deflate"
>>???? , CurlReferer "https://172.16.1.18/showWebForwards.do";
>>?? ]
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>



-- 
=====================
Patrick LeBoutillier
Rosem?re, Qu?bec, Canada



------------------------------

Message: 4
Date: Sat, 15 Jan 2011 09:43:31 +0100
From: Kamil Stachowski <[email protected]>
Subject: Re: [Haskell-beginners] IO String inside a CmdArgs data
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

It works! Thank you!

I didn't know Haskell has such a great community.

Thanks again,
Kamil Stachowski


On 14 January 2011 23:40, Daniel Fischer
<[email protected]>wrote:

> On Friday 14 January 2011 21:45:49, Kamil Stachowski wrote:
> > It is funny, indeed :)
> >
> > In fact, I am after all going to get unsafe because what Daniel Fischer
> > wrote above worked perfectly until I wanted to add annotations to ftConf
> > (the "&= summary" bit in http://community.haskell.org/~ndm/cmdargs/).
> > The only way I can go around the errors I get is precisely unsafe, so
> > ah, you only live once ;)
>
> Well, you could try
>
> setTime :: FuzzyTimeConf -> IO FuzzyTimeConf
> setTime ftc = do
>  now <- getClockTime
>  return $ ftc{ time = convert now }
>
> -- put annotations here
> defaultFuzzyTimeConf = FuzzyTimeConf { ... }
>
> main = do
>  realFTConf <- setTime defaultTimeConf
>  print =<< cmdArgs realFTConf
>
> I haven't looked at cmdargs, so I've no idea whether that'll work, but it
> may be worth a try.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110115/34192b65/attachment-0001.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 31, Issue 14
*****************************************

Reply via email to