@@ -73,6 +73,29 @@ size_t _mapcache_curl_header_callback( void *ptr, size_t size, size_t nmemb, vo
7373 return size * nmemb ;
7474}
7575
76+ /*update val replacing {foo_header} with the Value of foo_header from the orginal request */
77+ static void _header_replace_str (mapcache_context * ctx , apr_table_t * headers , char * * val ) {
78+ char * value = * val ;
79+ char * start_tag , * end_tag ;
80+ start_tag = strchr (value ,'{' );
81+ while (start_tag ) {
82+ * start_tag = 0 ;
83+ end_tag = strchr (start_tag + 1 ,'}' );
84+ if (end_tag ) {
85+ const char * header_value ;
86+ * end_tag = 0 ;
87+ header_value = apr_table_get (headers ,start_tag + 1 );
88+ if (header_value ) {
89+ value = apr_pstrcat (ctx -> pool ,value ,header_value ,end_tag + 1 ,NULL );
90+ }
91+ * end_tag = '}' ;
92+ }
93+ * start_tag = '{' ;
94+ start_tag = strchr (value ,'{' );
95+ }
96+ * val = value ;
97+ }
98+
7699void mapcache_http_do_request (mapcache_context * ctx , mapcache_http * req , mapcache_buffer * data , apr_table_t * headers , long * http_code )
77100{
78101 CURL * curl_handle ;
@@ -115,7 +138,11 @@ void mapcache_http_do_request(mapcache_context *ctx, mapcache_http *req, mapcach
115138 apr_table_entry_t * elts = (apr_table_entry_t * ) array -> elts ;
116139 int i ;
117140 for (i = 0 ; i < array -> nelts ; i ++ ) {
118- curl_headers = curl_slist_append (curl_headers , apr_pstrcat (ctx -> pool ,elts [i ].key ,": " ,elts [i ].val ,NULL ));
141+ char * val = elts [i ].val ;
142+ if (strchr (val ,'{' ) && ctx -> headers_in ) {
143+ _header_replace_str (ctx ,ctx -> headers_in ,& val );
144+ }
145+ curl_headers = curl_slist_append (curl_headers , apr_pstrcat (ctx -> pool ,elts [i ].key ,": " ,val ,NULL ));
119146 }
120147 }
121148 if (!req -> headers || !apr_table_get (req -> headers ,"User-Agent" )) {
0 commit comments