--- /dev/null
+Subject: res_http_media_cache
+
+When fetching a file for playback from a URL, Asterisk will now first
+use the value of the Content-Type header in the HTTP response to
+determine the format of the audio data, and only if it is unable to do
+that will it attempt to parse the URL and extract the extension from
+the path portion. Previously Asterisk would first look at the end of
+the URL, which may have included query string parameters or a URL
+fragment, which was error prone.
return NULL;
}
-static char *file_extension_from_url(struct ast_bucket_file *bucket_file, char *buffer, size_t capacity)
-{
- return file_extension_from_string(ast_sorcery_object_get_id(bucket_file), buffer, capacity);
-}
-
/*!
* \internal
* \brief Normalize the value of a Content-Type header
static void bucket_file_set_extension(struct ast_bucket_file *bucket_file)
{
- /* We will attempt to determine an extension in the following order for backwards
- * compatibility:
- *
- * 1. Look at tail end of URL for extension
- * 2. Use the Content-Type header if present
- * 3. Parse the URL (assuming we can) and look at the tail of the path
- */
+ /* Using Content-Type first allows for the most flexibility for whomever
+ * is serving up the audio file. If that doesn't turn up anything useful
+ * we'll try to parse the URL and use the extension */
char buffer[64];
- if (file_extension_from_url(bucket_file, buffer, sizeof(buffer))
- || file_extension_from_content_type(bucket_file, buffer, sizeof(buffer))
+ if (file_extension_from_content_type(bucket_file, buffer, sizeof(buffer))
|| file_extension_from_url_path(bucket_file, buffer, sizeof(buffer))) {
ast_bucket_file_metadata_set(bucket_file, "ext", buffer);
}