Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Parsing error #35

Open
CGenie opened this issue Feb 2, 2019 · 8 comments
Open

Parsing error #35

CGenie opened this issue Feb 2, 2019 · 8 comments

Comments

@CGenie
Copy link

CGenie commented Feb 2, 2019

Hello,
I'm trying to run a simple Imap.uid_search followed by Imap.uid_fetch for a Imap.Fetch.Request.body_section. Hover I'm getting this error:

Fatal error: exception Parsing error:
* 1 FETCH (UID 5 BODY[TEXT] {52}
                          ^

Any idea what's wrong here?

@nojb
Copy link
Owner

nojb commented Feb 2, 2019

Are you using master?

@CGenie
Copy link
Author

CGenie commented Feb 2, 2019

Yes, I'm using master, I liked the Lwt code more than the socket mangling as in the .1.1.1 release.

@CGenie
Copy link
Author

CGenie commented Feb 2, 2019

I'm aware it's a WIP, however I hoped for a minimal working version here, or at least small thing that can get fixed :)

@nojb
Copy link
Owner

nojb commented Feb 2, 2019

Can you tell which commit are you using? The current master has a completely different API which is not yet working.

@CGenie
Copy link
Author

CGenie commented Feb 2, 2019

I'm using the latest master with small fixes on top of it: https://github.com/CGenie/ocaml-imap/tree/master-fix

@CGenie
Copy link
Author

CGenie commented Feb 2, 2019

My code looks like this:

  Lwt_main.run begin
  Imap.connect ~host:host ~port:port ~username:username ~password:password >>= fun imap ->
  Imap.examine imap imap_cfg.mbox >>= fun () ->
  Imap.uid_search imap Imap.Search.all >>= fun (uids, _) ->
  (* Lwt_list.iter_s (fun (uid : Imap.uid) -> Lwt_io.printf "UID: %ld\n" uid) uids *)
  Lwt_list.iter_s (fun (uid: Imap.uid) ->
    let mime = Imap.MIME.Section.TEXT in
    let msg = Imap.uid_fetch imap [uid] [Imap.Fetch.Request.body_section ~peek:true ~section:([], Some mime) ()] in
    msg (fun resp ->
      match resp with
      | {Imap.Fetch.Response.body_section = [_, s]; _} ->
          Utils.log_with_header "UID: %ld\nBody: %s" uid s
      | _ ->
          Utils.log_with_header "Error fetching message %ld\n" uid
    )
  ) uids
  >>= fun () -> Imap.disconnect imap

@nojb
Copy link
Owner

nojb commented Feb 2, 2019

Probably due to https://github.com/CGenie/ocaml-imap/blob/master-fix/lib/parser.ml#L1156-L1161. You can try uncommenting that and seeing if it works. It may need some small changes to compile, not sure.

I can take a look but not right now, probably later in the day (no promises! :))

@CGenie
Copy link
Author

CGenie commented Feb 2, 2019

I'll try. Ah no hurry, your response is the fastest I've seen on github yet :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants