]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add nohead param to skip over the cache check with HEAD method
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 5 Oct 2012 15:14:22 +0000 (10:14 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 5 Oct 2012 15:14:22 +0000 (10:14 -0500)
src/mod/applications/mod_httapi/mod_httapi.c

index 35427c7b79c7b1b7da79b6f81eb0c1e074a4266f..845c342f63b07b2e23fed40b5dcffc2c021fd81d 100644 (file)
@@ -2530,37 +2530,41 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
 
        lock_file(context, SWITCH_TRUE);
 
-       if ((status = fetch_cache_data(context, url, &headers, NULL)) != SWITCH_STATUS_SUCCESS) {
-               if (status == SWITCH_STATUS_NOTFOUND) {
-                       unreachable = 2;
-                       if (now - context->expires < globals.not_found_expires) {
+       if (!context->url_params || !switch_true(switch_event_get_header(context->url_params, "nohead"))) {
+               if ((status = fetch_cache_data(context, url, &headers, NULL)) != SWITCH_STATUS_SUCCESS) {
+                       if (status == SWITCH_STATUS_NOTFOUND) {
+                               unreachable = 2;
+                               if (now - context->expires < globals.not_found_expires) {
+                                       switch_goto_status(SWITCH_STATUS_SUCCESS, end);
+                               }
+                       } else {
+                               unreachable = 1;
+                       }
+               }
+               
+               if (switch_file_exists(context->cache_file, context->pool) != SWITCH_STATUS_SUCCESS && unreachable) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File at url [%s] is unreachable!\n", url);
+                       goto end;
+               }
+               
+               if (!unreachable && !zstr(context->metadata)) {
+                       metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s",
+                                                                                  url,
+                                                                                  switch_event_get_header_nil(headers, "last-modified"),
+                                                                                  switch_event_get_header_nil(headers, "etag"),
+                                                                                  switch_event_get_header_nil(headers, "content-length")
+                                                                                  );
+
+                       if (!strcmp(metadata, context->metadata)) {
+                               write_meta_file(context, metadata, headers);
                                switch_goto_status(SWITCH_STATUS_SUCCESS, end);
                        }
-               } else {
-                       unreachable = 1;
                }
+               
+               switch_event_destroy(&headers);
        }
 
-       if (switch_file_exists(context->cache_file, context->pool) != SWITCH_STATUS_SUCCESS && unreachable) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File at url [%s] is unreachable!\n", url);
-               goto end;
-       }
-
-       if (!unreachable && !zstr(context->metadata)) {
-               metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s",
-                                                                          url,
-                                                                          switch_event_get_header_nil(headers, "last-modified"),
-                                                                          switch_event_get_header_nil(headers, "etag"),
-                                                                          switch_event_get_header_nil(headers, "content-length")
-                                                                          );
 
-               if (!strcmp(metadata, context->metadata)) {
-                       write_meta_file(context, metadata, headers);
-                       switch_goto_status(SWITCH_STATUS_SUCCESS, end);
-               }
-       }
-
-       switch_event_destroy(&headers);
        fetch_cache_data(context, url, &headers, context->cache_file);
        metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s",
                                                                   url,