Skip to content

Commit

Permalink
Merge branch 'branch-1-4' into dimension-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Nov 6, 2015
2 parents 26908d9 + ae1147b commit 08dfca6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
36 changes: 20 additions & 16 deletions apache/mod_mapcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,27 +261,29 @@ static void read_post_body(mapcache_context_apache_request *ctx, mapcache_reques
p->post_len = 0;

do {
apr_bucket *nextb;
rv = ap_get_brigade(r->input_filters, bbin, AP_MODE_READBYTES, APR_BLOCK_READ, bytes);
if(rv != APR_SUCCESS) {
mctx->set_error(mctx, 500, "failed to read form input");
return;
}
for(b = APR_BRIGADE_FIRST(bbin); b != APR_BRIGADE_SENTINEL(bbin); b = APR_BUCKET_NEXT(b)) {
for(b = APR_BRIGADE_FIRST(bbin); b != APR_BRIGADE_SENTINEL(bbin); b = nextb) {
nextb = APR_BUCKET_NEXT(b);
if(APR_BUCKET_IS_EOS(b)) {
eos = 1;
}
}
if(!APR_BUCKET_IS_METADATA(b)) {
if(b->length != (apr_size_t)(-1)) {
p->post_len += b->length;
if(p->post_len > p->rule->max_post_len) {
apr_bucket_delete(b);
if(!APR_BUCKET_IS_METADATA(b)) {
if(b->length != (apr_size_t)(-1)) {
p->post_len += b->length;
if(p->post_len > p->rule->max_post_len) {
apr_bucket_delete(b);
}
}
}
}
if(p->post_len <= p->rule->max_post_len) {
APR_BUCKET_REMOVE(b);
APR_BRIGADE_INSERT_TAIL(bb, b);
if(p->post_len <= p->rule->max_post_len) {
APR_BUCKET_REMOVE(b);
APR_BRIGADE_INSERT_TAIL(bb, b);
}
}
} while (!eos);

Expand All @@ -291,11 +293,13 @@ static void read_post_body(mapcache_context_apache_request *ctx, mapcache_reques
}

p->post_buf = apr_palloc(mctx->pool, p->post_len+1);

rv = apr_brigade_flatten(bb, p->post_buf, &(p->post_len));
if(rv != APR_SUCCESS) {
mctx->set_error(mctx, 500, "error (flatten) reading form data");
return;

if(p->post_len> 0) {
rv = apr_brigade_flatten(bb, p->post_buf, &(p->post_len));
if(rv != APR_SUCCESS) {
mctx->set_error(mctx, 500, "error (flatten) reading form data");
return;
}
}
p->post_buf[p->post_len] = 0;
}
Expand Down
16 changes: 13 additions & 3 deletions lib/cache_riak.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static int _mapcache_cache_riak_get(mapcache_context *ctx, mapcache_cache *pcach
* \sa mapcache_cache::tile_set()
*/
static void _mapcache_cache_riak_set(mapcache_context *ctx, mapcache_cache *pcache, mapcache_tile *tile) {
char *key;
char *key,*content_type;
int error;
int connect_error = RIACK_SUCCESS;
int retries = 3;
Expand Down Expand Up @@ -311,6 +311,16 @@ static void _mapcache_cache_riak_set(mapcache_context *ctx, mapcache_cache *pcac
tile->encoded_data = tile->tileset->format->write(ctx, tile->raw_image, tile->tileset->format);
GC_CHECK_ERROR(ctx);
}
content_type = tile->tileset->format?(tile->tileset->format->mime_type?tile->tileset->format->mime_type:NULL):NULL;

if(!content_type) {
/* compute the content-type */
mapcache_image_format_type t = mapcache_imageio_header_sniff(ctx,tile->encoded_data);
if(t == GC_PNG)
content_type = "image/png";
else if(t == GC_JPEG)
content_type = "image/jpeg";
}

pc = _riak_get_connection(ctx, cache, tile);
GC_CHECK_ERROR(ctx);
Expand All @@ -324,8 +334,8 @@ static void _mapcache_cache_riak_set(mapcache_context *ctx, mapcache_cache *pcac
object.vclock.len = 0;
object.content_count = 1;
object.content = &content;
content.content_type.value = tile->tileset->format->mime_type;
content.content_type.len = strlen(tile->tileset->format->mime_type);
content.content_type.value = content_type;
content.content_type.len = content_type?strlen(content_type):0;
content.data = (uint8_t*)tile->encoded_data->buf;
content.data_len = tile->encoded_data->size;

Expand Down
2 changes: 1 addition & 1 deletion lib/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void mapcache_http_do_request(mapcache_context *ctx, mapcache_http *req, mapcach
char error_msg[CURL_ERROR_SIZE];
int ret;
struct curl_slist *curl_headers=NULL;
struct _header_struct h;
curl_handle = curl_easy_init();


Expand All @@ -121,7 +122,6 @@ void mapcache_http_do_request(mapcache_context *ctx, mapcache_http *req, mapcach

if(headers != NULL) {
/* intercept headers */
struct _header_struct h;
h.headers = headers;
h.ctx=ctx;
curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, _mapcache_curl_header_callback);
Expand Down

0 comments on commit 08dfca6

Please sign in to comment.