[mapserver-commits] r12277 - in trunk/mapserver/mapcache: include src

svn at osgeo.org svn at osgeo.org
Fri Aug 26 07:13:14 EDT 2011


Author: tbonfort
Date: 2011-08-26 04:13:14 -0700 (Fri, 26 Aug 2011)
New Revision: 12277

Modified:
   trunk/mapserver/mapcache/include/geocache.h
   trunk/mapserver/mapcache/src/http.c
   trunk/mapserver/mapcache/src/source_wms.c
Log:
add KML superoverlays
thomas.bonfort | 2011-01-21 10:39:06 +0100 (Fri, 21 Jan 2011)

Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:13:09 UTC (rev 12276)
+++ trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:13:14 UTC (rev 12277)
@@ -46,6 +46,8 @@
 #define GEOCACHE_CACHE_MISS 5
 #define GEOCACHE_FILE_LOCKED 6
 
+#define GEOCACHE_VERSION "0.3-dev"
+#define GEOCACHE_USERAGENT "geocache/"GEOCACHE_VERSION
 
 
 
@@ -544,8 +546,8 @@
 
 /** \defgroup http HTTP Request handling*/
 /** @{ */
-void geocache_http_request_url(geocache_context *ctx, char *url, geocache_buffer *data);
-void geocache_http_request_url_with_params(geocache_context *ctx, char *url, apr_table_t *params, geocache_buffer *data);
+void geocache_http_request_url(geocache_context *ctx, char *url, apr_table_t *headers, geocache_buffer *data);
+void geocache_http_request_url_with_params(geocache_context *ctx, char *url, apr_table_t *params, apr_table_t *headers, geocache_buffer *data);
 char* geocache_http_build_url(geocache_context *ctx, char *base, apr_table_t *params);
 apr_table_t *geocache_http_parse_param_string(geocache_context *ctx, char *args);
 /** @} */

Modified: trunk/mapserver/mapcache/src/http.c
===================================================================
--- trunk/mapserver/mapcache/src/http.c	2011-08-26 11:13:09 UTC (rev 12276)
+++ trunk/mapserver/mapcache/src/http.c	2011-08-26 11:13:14 UTC (rev 12277)
@@ -28,7 +28,7 @@
    return geocache_buffer_append(buffer, realsize, ptr);
 }
 
-void geocache_http_request_url(geocache_context *ctx, char *url, geocache_buffer *data) {
+void geocache_http_request_url(geocache_context *ctx, char *url, apr_table_t *headers, geocache_buffer *data) {
    CURL *curl_handle;
    curl_handle = curl_easy_init();
    int ret;
@@ -48,9 +48,20 @@
    curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
    curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
 
-   /* some servers don't like requests that are made without a user-agent field, so we provide one */ 
-   curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "mod_geocache/0.1");
 
+   struct curl_slist *curl_headers=NULL;
+   if(headers) {
+      const apr_array_header_t *array = apr_table_elts(headers);
+      apr_table_entry_t *elts = (apr_table_entry_t *) array->elts;
+      int i;
+      for (i = 0; i < array->nelts; i++) {
+         curl_headers = curl_slist_append(curl_headers, apr_pstrcat(ctx->pool,elts[i].key,": ",elts[i].val,NULL));
+      }
+   }
+   if(!headers || !apr_table_get(headers,"User-Agent")) {
+      curl_headers = curl_slist_append(curl_headers, "User-Agent: "GEOCACHE_USERAGENT);
+   }
+   curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, curl_headers);
    /* get it! */ 
    ret = curl_easy_perform(curl_handle);
    if(ret != CURLE_OK) {
@@ -60,9 +71,9 @@
    curl_easy_cleanup(curl_handle);
 }
 
-void geocache_http_request_url_with_params(geocache_context *ctx, char *url, apr_table_t *params, geocache_buffer *data) {
+void geocache_http_request_url_with_params(geocache_context *ctx, char *url, apr_table_t *params, apr_table_t *headers, geocache_buffer *data) {
    char *fullUrl = geocache_http_build_url(ctx,url,params);
-   geocache_http_request_url(ctx,fullUrl,data);
+   geocache_http_request_url(ctx,fullUrl,headers,data);
 }
 
 /* calculate the length of the string formed by key=value&, and add it to cnt */

Modified: trunk/mapserver/mapcache/src/source_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/source_wms.c	2011-08-26 11:13:09 UTC (rev 12276)
+++ trunk/mapserver/mapcache/src/source_wms.c	2011-08-26 11:13:14 UTC (rev 12277)
@@ -44,7 +44,7 @@
  
     }      
     tile->tile.data = geocache_buffer_create(30000,ctx->pool);
-    geocache_http_request_url_with_params(ctx,wms->url,params,tile->tile.data);
+    geocache_http_request_url_with_params(ctx,wms->url,params,NULL,tile->tile.data);
     GC_CHECK_ERROR(ctx);
  
     if(!geocache_imageio_is_valid_format(ctx,tile->tile.data)) {



More information about the mapserver-commits mailing list