From cca965e288b40ddfea9ebee006f64590f27d8697 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Sat, 4 May 2013 13:23:05 +0200 Subject: [PATCH] get etag header out of PUT reply. --- src/httpbf/src/httpbf.c | 13 +++++++++++-- src/httpbf/src/httpbf.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/httpbf/src/httpbf.c b/src/httpbf/src/httpbf.c index effd5ae30..deed15b9e 100644 --- a/src/httpbf/src/httpbf.c +++ b/src/httpbf/src/httpbf.c @@ -173,6 +173,7 @@ void hbf_free_transfer( hbf_transfer_t *transfer ) { for( cnt = 0; cnt < transfer->block_cnt; cnt++ ) { hbf_block_t *block = transfer->block_arr[cnt]; if( block->http_error_msg ) free( block->http_error_msg ); + if( block->etag ) free( block->etag ); if( block ) free(block); } free( transfer->block_arr ); @@ -261,9 +262,17 @@ static int dav_request( ne_request *req, int fd, hbf_block_t *blk ) { if( req_status->klass == 2 ) { etag = ne_get_response_header(req, "ETag"); if (etag && etag[0]) { - state = HBF_SUCCESS; - blk->state = HBF_TRANSFER_SUCCESS; + if( etag[0] == '"' && etag[ strlen(etag)-1] == '"') { + int len = strlen( etag )-2; + blk->etag = malloc( len+1 ); + strncpy( blk->etag, etag+1, len ); + blk->etag[len] = '\0'; + } else { + blk->etag = strdup( etag ); + } } + state = HBF_SUCCESS; + blk->state = HBF_TRANSFER_SUCCESS; } break; case NE_AUTH: diff --git a/src/httpbf/src/httpbf.h b/src/httpbf/src/httpbf.h index b61fb7779..a2010988f 100644 --- a/src/httpbf/src/httpbf.h +++ b/src/httpbf/src/httpbf.h @@ -58,6 +58,7 @@ struct hbf_block_s { Hbf_State state; int http_result_code; char *http_error_msg; + char *etag; int tries; };