http_prefetch does not work with parameter profile

Peiffer Eric eric.peiffer at al-enterprise.com
Wed Mar 1 08:49:46 UTC 2023


Hi

I used the mod_http_cache modul in order to manage a cache of audio files. I have a new profile in the http_cache.conf.xml:

   <profiles>
      <profile name="swift">
        <default>
                <header name="Authorization">Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJjb3Vu...g</header>
       </default>
      </profile>
   </profiles>

In fs_cli when I call

http_get {profile=swift]http://xx.xx.xx.xx:pppp/audio.mp3 (xx.xx.xx.xx ip and pppp the port of our swift web server)

The profile "swift" is well used in order to  add the header Authorization into the GET HTTP request, and the audio file is well added to the cache.
But if I used the http_prefetch the command failed:

freeswitch at fs1> http_prefetch {profile=swift}http://xx.xx.xx.xx:pppp/acdc.mp3
+OK

2023-03-01 09:38:34.351425 99.70% [DEBUG] mod_http_cache.c:659 Locked cache
2023-03-01 09:38:34.351425 99.70% [INFO] mod_http_cache.c:751 Cache MISS: size = 15 (70 MB), hit ratio = 4/20
2023-03-01 09:38:34.351425 99.70% [DEBUG] mod_http_cache.c:816 Adding {profile=swift}http://xx.xx.xx.xx:pppp/audio.mp3(/var/cache/freeswitch/15/2a01eb-0e9a-4988-a7e3-40c80c1c9c52.mp3) to cache index 15
2023-03-01 09:38:34.351425 99.70% [DEBUG] mod_http_cache.c:670 Unlocked cache
2023-03-01 09:38:34.351425 99.70% [DEBUG] mod_http_cache.c:1126 opening /var/cache/freeswitch/15/2a01eb-0e9a-4988-a7e3-40c80c1c9c52.mp3 for URL cache
2023-03-01 09:38:34.351425 99.70% [ERR] mod_http_cache.c:1187 Received curl error 3 HTTP error code 0 trying to fetch {profile=swift}http://xx.xx.xx.xx:pppp/audio.mp3
2023-03-01 09:38:34.351425 99.70% [DEBUG] mod_http_cache.c:659 Locked cache
2023-03-01 09:38:34.351425 99.70% [INFO] mod_http_cache.c:773 Failed to download URL {profile=swift}http://xx.xx.xx.xx:pppp/audio.mp3
2023-03-01 09:38:34.351425 99.70% [DEBUG] mod_http_cache.c:670 Unlocked cache


When I read the mod_http_cache.c source code in the http_cache_prefetch function it seems that the parameter prefetch is added to the command
without checking if other parameters are added:
url = switch_mprintf("{prefetch=true}%s", cmd);

this result of a bad url: {prefetch=true}{profile=swift}http://xx.xx.xx.xx:pppp/audio.mp3, and maybe this is why curl return an error.

How can i use http_prefetch with a profile?
Thanks Eric.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20230301/05b09a6b/attachment.html>


More information about the FreeSWITCH-users mailing list