Index: include/libroar/vio_proto.h
===================================================================
--- include/libroar/vio_proto.h	(revision 3517)
+++ include/libroar/vio_proto.h	(revision 4582)
@@ -56,4 +56,5 @@
   struct roar_buffer * mdbuf;
  } metadata;
+ char * content_type;
 };
 
Index: libroar/vio_proto.c
===================================================================
--- libroar/vio_proto.c	(revision 3795)
+++ libroar/vio_proto.c	(revision 4582)
@@ -247,4 +247,11 @@
     return 0;
    break;
+  case ROAR_VIO_CTL_GET_MIMETYPE:
+    if ( data == NULL )
+     return -1;
+
+    *(char**)data = self->content_type;
+    return 0;
+   break;
  }
 
@@ -258,4 +265,7 @@
   return -1;
 
+ if ( self->content_type != NULL )
+  roar_mm_free(self->content_type);
+
  roar_mm_free(self);
 
@@ -263,6 +273,93 @@
 }
 
+static int _parse_header(struct roar_keyval * kv, char ** buf, int * aligned) {
+ char * p = *buf;
+ char   c = 0;
+
+ if ( !(*aligned) ) {
+  for (; *p != 0 && *p != '\r' && *p != '\n'; p++);
+  p++;
+  if ( *p == '\n' )
+   p++;
+ }
+
+ kv->key = p;
+
+ for (; *p != 0 && *p != '\r' && *p != '\n' && *p != ':'; p++);
+
+ if ( *p == 0 )
+  return -1;
+
+ c = *p;
+ *p = 0;
+
+ if ( c == '\r' && *(p+1) == '\n' )
+  p++;
+
+ p++;
+
+ if ( c == '\r' || c == '\n' ) {
+  if ( *(kv->key) == '\r' || *(kv->key) == '\n' )
+   return 0;
+//  printf("Key-only\n");
+  kv->value = kv->key;
+  kv->key   = NULL;
+  *buf = p;
+  return 1;
+ }
+
+ for (; *p == ' '; p++);
+
+ if ( *p == 0 )
+  return -1;
+
+ kv->value = p;
+
+ for (; *p != 0 && *p != '\r' && *p != '\n'; p++);
+
+ if ( *p == 0 )
+  return -1;
+
+ c = *p;
+ *p = 0;
+
+ if ( c == '\r' && *(p+1) == '\n' )
+  p++;
+
+ p++;
+
+ *buf = p;
+
+ if ( c == '\r' || c == '\n' ) {
+//  printf("aligned\n");
+  *aligned = 1;
+  p++;
+ } else {
+//  printf("non-aligned(c=0x%x)\n", (int)c);
+  *aligned = 0;
+ }
+
+ if ( *(kv->key) != 0 )
+  return 1;
+
+ return 0;
+}
+
+static void _handle_header (struct roar_vio_proto * self, struct roar_keyval * kv) {
+ ROAR_DBG("_handle_header(*): Header: key='%s', value='%s'", kv->key, kv->value);
+
+ if ( kv->key == NULL || kv->value == NULL )
+  return;
+
+ if ( !strcasecmp(kv->key, "Content-Type") ) {
+  if ( self->content_type != NULL )
+   roar_mm_free(self->content_type);
+
+  self->content_type = roar_mm_strdup(kv->value);
+ }
+}
 
 int roar_vio_open_proto_http   (struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * host, char * file) {
+ struct roar_keyval kv;
  struct roar_vio_proto * self;
  struct roar_buffer * bufbuf;
@@ -270,7 +367,10 @@
  char * buf;
  char * endofheader = NULL;
+ char * p;
  char b0[80], b1[80];
  int  status;
  int  len;
+ int  oeflen = 4;
+ int  aligned = 1;
 
  ROAR_DBG("roar_vio_open_proto_http(calls=%p, dst=%p, host='%s', file='%s') = ?", calls, dst, host, file);
@@ -329,6 +429,15 @@
 
  endofheader = strstr(buf, "\r\n\r\n");
+ if ( endofheader == NULL ) {
+  endofheader = strstr(buf, "\n\n");
+  oeflen = 2;
+ }
 
  ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader);
+
+ p = buf;
+ while ( _parse_header(&kv, &p, &aligned) > 0 )
+  if ( aligned )
+   _handle_header(self, &kv);
 
  while ( endofheader == NULL ) {
@@ -338,4 +447,15 @@
   buf[len] = 0;
   endofheader = strstr(buf, "\r\n\r\n");
+  if ( endofheader == NULL ) {
+   endofheader = strstr(buf, "\n\n");
+   oeflen = 2;
+  }
+
+/* Doesn't work good.
+  while ( _parse_header(&kv, &p, &aligned) > 0 )
+   if ( aligned )
+    _handle_header(self, &kv);
+*/
+
   ROAR_DBG("roar_vio_open_proto_http(*): endofheader=%p\n", endofheader);
  }
@@ -344,5 +464,5 @@
  ROAR_DBG("roar_vio_open_proto_http(*): buf=%p\n", buf);
 
- if ( (endofheader - buf) == (len - 4) ) {
+ if ( (endofheader - buf) == (len - oeflen) ) {
   roar_buffer_free(bufbuf);
   bufbuf = NULL;
@@ -350,6 +470,6 @@
 
  if ( bufbuf != NULL ) {
-  roar_buffer_set_offset(bufbuf, endofheader - buf + 4);
-  roar_buffer_set_len(bufbuf,    len - (endofheader - buf + 4) - 1);
+  roar_buffer_set_offset(bufbuf, endofheader - buf + oeflen);
+  roar_buffer_set_len(bufbuf,    len - (endofheader - buf + oeflen) - 1);
  }
  self->reader.buffer = bufbuf;
