Re: [gmime-devel] Dumping of headers ignores mime-type



Hi Steve,

On 11/1/2013 7:46 PM, Steve Kemp wrote:
   I've written a scratch program to dump all headers from
  a message:

     https://github.com/skx/lumail/blob/master/util/dump-headers.c

FWIW, you don't need to call iter_first() here:

if (g_mime_header_list_get_iter (ls, iter) && g_mime_header_iter_first (iter))

When you get the iterator, it starts at the first one.


   This seems to work, but crucially it doesn't show the MIME-Type
  of the message:

shelob ~/git/lumail/util $ ./dump-headers
~/Maildir/.github.com/cur/1382702258.26372_2.ssh.steve.org.uk:2,S  |grep -i type


   Yet when I examine a message manually I see the expected headers
  containing content-type:
  shelob ~/git/lumail/util $ grep -i type ~/Maildir/.github.com/cur/1382702258.26372_2.ssh.steve.org.uk:2,S
  Content-Type: multipart/alternative;
  Content-Type: text/plain;
  Content-Type: text/html;


   Is there some trick to using g_mime_header_list_get_iter to avoid
  skipping headers?

Once you finish with the GMimeMessage headers, you'll want to iterate over the headers of the message's mime part (to get the Content-*) headers because the mime headers are stored on the mime parts themselves and not the message object.

If you want to get all headers of all mime parts within the message, you'll also need to traverse the mime hierarchy - but I suspect you only care about the top-level mime headers.

Hope that helps,

Jeff




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]