[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dav-cvs
Subject:    [dav-checkins] CVS: mod_dav mod_dav.c
From:       Greg Stein (CVS user) <gjscvs () nebula ! lyra ! org>
Date:       2000-05-30 9:41:10
[Download RAW message or body]

gjscvs      00/05/30 02:41:09

  Modified:    .        mod_dav.c
  Log:
  implement Content-Range for PUT methods
  
  Revision  Changes    Path
  1.118     +27 -2     mod_dav/mod_dav.c
  
  Index: mod_dav.c
  ===================================================================
  RCS file: /home/cvsroot/mod_dav/mod_dav.c,v
  retrieving revision 1.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- mod_dav.c	2000/05/30 08:47:19	1.117
  +++ mod_dav.c	2000/05/30 09:41:09	1.118
  @@ -994,6 +994,9 @@
       dav_stream_mode mode;
       dav_stream *stream;
       dav_response *multi_response;
  +    int has_range;
  +    off_t range_start;
  +    off_t range_end;
   
       if ((result = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)) != OK) {
   	return result;
  @@ -1050,9 +1053,15 @@
   	return dav_handle_err(r, err, NULL);
       }
   
  -    /* Create the new file in the repository */
  -    /* ### use DAV_MODE_WRITE_SEEKABLE if a Content-Range is present */
  +    /* truncate and rewrite the file unless we see a Content-Range */
       mode = DAV_MODE_WRITE_TRUNC;
  +
  +    has_range = dav_parse_range(r, &range_start, &range_end);
  +    if (has_range) {
  +        mode = DAV_MODE_WRITE_SEEKABLE;
  +    }
  +
  +    /* Create the new file in the repository */
       if ((err = (*resource->hooks->open_stream)(resource, mode,
                                                  &stream)) != NULL) {
   	/* ### assuming FORBIDDEN is probably not quite right... */
  @@ -1063,11 +1072,22 @@
   			     err);
       }
   
  +    if (err == NULL && has_range) {
  +        /* a range was provided. seek to the start */
  +        err = (*resource->hooks->seek_stream)(stream, range_start);
  +    }
  +
       if (err == NULL) {
           if (ap_should_client_block(r)) {
   	    char *buffer = ap_palloc(r->pool, DAV_READ_BLOCKSIZE);
   	    int len;
   
  +            /*
  +            ** Once we start reading the request, then we must read the
  +            ** whole darn thing. ap_discard_request_body() won't do anything
  +            ** for a partially-read request.
  +            */
  +
   	    while ((len = ap_get_client_block(r, buffer,
   					      DAV_READ_BLOCKSIZE)) > 0) {
   		if (err == NULL) {
  @@ -1076,6 +1096,11 @@
                                                              buffer, len);
   		}
   	    }
  +
  +            /*
  +            ** ### what happens if we read more/less than the amount
  +            ** ### specified in the Content-Range? eek...
  +            */
   
   	    if (len == -1) {
   		/*
  
  
  

_______________________________________________
dav-checkins maillist  -  dav-checkins@lyra.org
http://dav.lyra.org/mailman/listinfo/dav-checkins

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic