Index: include/libroar/vio_dstr.h
===================================================================
--- include/libroar/vio_dstr.h	(revision 1349)
+++ include/libroar/vio_dstr.h	(revision 1353)
@@ -160,4 +160,5 @@
 
 int     roar_vio_dstr_init_defaults (struct roar_vio_defaults * def, int type, int o_flags, mode_t o_mode);
+int     roar_vio_dstr_init_defaults_c (struct roar_vio_defaults * def, int type, struct roar_vio_defaults * odef, int o_flags);
 
 int     roar_vio_open_default (struct roar_vio_calls * calls, struct roar_vio_defaults * def);
Index: libroar/vio_dstr.c
===================================================================
--- libroar/vio_dstr.c	(revision 1350)
+++ libroar/vio_dstr.c	(revision 1353)
@@ -168,4 +168,15 @@
 }
 
+int     roar_vio_dstr_init_defaults_c (struct roar_vio_defaults * def, int type, struct roar_vio_defaults * odef, int o_flags) {
+ if ( o_flags < 1 )
+  o_flags = O_RDONLY;
+
+ if ( odef == NULL ) {
+  return roar_vio_dstr_init_defaults(def, type, o_flags, 0644);
+ } else {
+  return roar_vio_dstr_init_defaults(def, type, odef->o_flags, odef->o_mode);
+ }
+}
+
 int     roar_vio_open_default (struct roar_vio_calls * calls, struct roar_vio_defaults * def) {
  if ( calls == NULL || def == NULL )
@@ -389,9 +400,5 @@
      c->need_vio = 0;
      next->def = &(next->store_def);
-     if ( c->def != NULL ) {
-      roar_vio_dstr_init_defaults(next->def, ROAR_VIO_DEF_TYPE_FILE, c->def->o_flags, c->def->o_mode);
-     } else {
-      roar_vio_dstr_init_defaults(next->def, ROAR_VIO_DEF_TYPE_FILE, O_RDONLY, 0644);
-     }
+     roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_FILE, c->def, -1);
 
      if ( c->dst[0] == '/' && c->dst[1] == '/' ) {
@@ -438,12 +445,12 @@
 
      if ( c->dst == NULL ) { // we don't have a destination? -> slow way
+      if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+       return -1;
+
       if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_UNIX, SOCK_STREAM, c->def) == -1 )
        return -1;
      } else {                // we have a destination? -> fast way
-      if ( c->def != NULL ) {
-       roar_vio_dstr_init_defaults(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def->o_flags, c->def->o_mode);
-      } else {
-       roar_vio_dstr_init_defaults(next->def, ROAR_VIO_DEF_TYPE_SOCKET, O_WRONLY, 0644);
-      }
+      if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+       return -1;
 
       if ( roar_vio_socket_init_unix_def(next->def, c->dst) == -1 )
@@ -456,4 +463,7 @@
      next->def = &(next->store_def);
 
+     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+      return -1;
+
      if ( roar_vio_socket_init_dstr_def(next->def, c->dst, -1, SOCK_STREAM, c->def) == -1 )
       return -1;
@@ -464,4 +474,7 @@
      next->def = &(next->store_def);
 
+     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+      return -1;
+
      if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_DECnet, SOCK_STREAM, c->def) == -1 )
       return -1;
@@ -472,4 +485,7 @@
      next->def = &(next->store_def);
 
+     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+      return -1;
+
      if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET, SOCK_STREAM, c->def) == -1 )
       return -1;
@@ -478,4 +494,7 @@
      c->need_vio = 0;
      next->def = &(next->store_def);
+
+     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+      return -1;
 
      if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET, SOCK_DGRAM, c->def) == -1 )
@@ -487,4 +506,7 @@
      next->def = &(next->store_def);
 
+     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+      return -1;
+
      if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET6, SOCK_STREAM, c->def) == -1 )
       return -1;
@@ -493,4 +515,7 @@
      c->need_vio = 0;
      next->def = &(next->store_def);
+
+     if ( roar_vio_dstr_init_defaults_c(next->def, ROAR_VIO_DEF_TYPE_SOCKET, c->def, O_WRONLY) == -1 )
+      return -1;
 
      if ( roar_vio_socket_init_dstr_def(next->def, c->dst, AF_INET6, SOCK_DGRAM, c->def) == -1 )
@@ -524,5 +549,5 @@
                     next->def, next->def == NULL ? -1 : next->def->type);
    if ( next->def != NULL ) {
-    ROAR_DBG("roar_vio_dstr_set_defaults(*): i=%i, c->type=0x%.4x(%s): next->def->o_flags=%i", i,
+    ROAR_WARN("roar_vio_dstr_set_defaults(*): i=%i, c->type=0x%.4x(%s): next->def->o_flags=%i", i,
                      c->type & 0xFFFF, roar_vio_dstr_get_name(c->type),
                      next->def->o_flags);
@@ -582,6 +607,6 @@
 
  for (i = 0; (c = &chain[i])->type != ROAR_VIO_DSTR_OBJT_EOL; i++) {
-  ROAR_DBG("roar_vio_dstr_build_chain(*): i=%i, c->type=0x%.4x(%s): need_vio=%i", i,
-                   c->type & 0xFFFF, roar_vio_dstr_get_name(c->type), c->need_vio);
+  ROAR_DBG("roar_vio_dstr_build_chain(*): i=%i, c->type=0x%.4x(%s): need_vio=%i, def->o_flags=%i", i,
+                   c->type & 0xFFFF, roar_vio_dstr_get_name(c->type), c->need_vio, c->def->o_flags);
 
   if ( c->need_vio ) {
@@ -625,5 +650,5 @@
     case ROAR_VIO_DSTR_OBJT_HTTP10:
     case ROAR_VIO_DSTR_OBJT_HTTP11:
-      if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_HTTP, i == 0 ? NULL : chain[i-1].def) == -1 ) {
+      if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_HTTP, c->def) == -1 ) {
        _ret(-1);
       }
@@ -631,5 +656,5 @@
     case ROAR_VIO_DSTR_OBJT_GOPHER:
     case ROAR_VIO_DSTR_OBJT_GOPHER_PLUS:
-      if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_GOPHER, i == 0 ? NULL : chain[i-1].def) == -1 ) {
+      if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_GOPHER, c->def) == -1 ) {
        _ret(-1);
       }
Index: libroar/vio_proto.c
===================================================================
--- libroar/vio_proto.c	(revision 1352)
+++ libroar/vio_proto.c	(revision 1353)
@@ -50,4 +50,7 @@
  }
 
+ if ( dstr == NULL )
+  dstr = "//";
+
  if ( roar_vio_dstr_init_defaults(def, ROAR_VIO_DEF_TYPE_SOCKET, O_RDWR, 0644) == -1 )
   return -1;
@@ -62,5 +65,9 @@
   *ed = 0;
 
+ ROAR_WARN("roar_vio_proto_init_def(*): def->o_flags=%i", def->o_flags);
+
  ret = roar_vio_socket_init_dstr_def(def, dstr, -1, SOCK_STREAM, def);
+
+ ROAR_WARN("roar_vio_proto_init_def(*): def->o_flags=%i", def->o_flags);
 
  if ( ed != NULL )
@@ -77,7 +84,8 @@
  ROAR_WARN("roar_vio_open_proto(calls=%p, dst=%p, dstr='%s', proto=%i, odef=%p) = ?", calls, dst, dstr, proto, odef);
 
- if ( calls == NULL || dst == NULL || dstr == NULL )
+ if ( calls == NULL || dst == NULL || odef == NULL )
   return -1;
 
+ ROAR_WARN("roar_vio_open_proto(*): odef->o_flags=%i", odef->o_flags);
  ROAR_DBG("roar_vio_open_proto(*) = ?");
 
@@ -85,17 +93,36 @@
   return -1;
 
- dstr += 2;
- host  = dstr;
+ ROAR_DBG("roar_vio_open_proto(*) = ?");
 
- if ( (tmp = strstr(dstr, "/")) == NULL )
-  return -1;
+ if ( dstr != NULL ) {
+  dstr += 2;
+  host  = dstr;
 
- *tmp++ = 0;
- dstr   = tmp;
+  if ( (tmp = strstr(dstr, "/")) == NULL )
+   return -1;
 
- if ( (tmp = strstr(dstr, "#")) != NULL )
-  *tmp = 0;
+  *tmp++ = 0;
+  dstr   = tmp;
+
+  if ( (tmp = strstr(dstr, "#")) != NULL )
+   *tmp = 0;
+ } else {
+  ROAR_DBG("roar_vio_open_proto(*): no dstr!, odef->type=%i", odef->type);
+  if ( odef->type == ROAR_VIO_DEF_TYPE_FILE ) {
+   dstr = odef->d.file;
+   host = "localhost";
+
+   for (; *dstr == '/'; dstr++);
+
+  } else if ( odef->type == ROAR_VIO_DEF_TYPE_SOCKET ) {
+   dstr = ""; // index document
+   host = odef->d.socket.host;
+  } else {
+   return -1;
+  }
+ }
 
  ROAR_DBG("roar_vio_open_proto(*) = ?");
+ ROAR_WARN("roar_vio_open_proto(*): proto=%i, host='%s', file='%s'", proto, host, dstr);
 
  switch (proto) {
Index: libroar/vio_socket.c
===================================================================
--- libroar/vio_socket.c	(revision 1350)
+++ libroar/vio_socket.c	(revision 1353)
@@ -230,5 +230,7 @@
    return -1;
 
-  memcpy(def, odef, sizeof(struct roar_vio_defaults));
+  if ( def != odef )
+   memcpy(def, odef, sizeof(struct roar_vio_defaults));
+
   return 0;
  }
