User Controls

Background Fetch doesn't work with redirects

  1. #1
    Soyboy IV: The Flower of Death and The Crystal of Life African Astronaut [the oppositely able-bodied hop-step-and-jump]
    Playing around with google's new background fetch API, but can't convince it to follow a redirect. Anyone have any idea how to fix or work around this (in javascript)?

    I'm making my own little podcast client based on code stolen from https://bgfetch-http203.glitch.me/
  2. #2
    Grylls Cum Looking Faggot [abrade this vocal tread-softly]
    posting in a nerd thred and inb4 nerd alts who just googled shit
  3. #3
    Soyboy IV: The Flower of Death and The Crystal of Life African Astronaut [the oppositely able-bodied hop-step-and-jump]
    Originally posted by Grylls posting in a nerd thred and inb4 nerd alts who just googled shit

    Modern software development is basically nothing but a big long google session. There's no shame in it.

    I'm sure the likes of Lanny can code blind and drunk.
  4. #4
    Grylls Cum Looking Faggot [abrade this vocal tread-softly]
    im sorry i dont understand this jargon stuffs

    but i wish you good luck m8
  5. #5
    esbity African Astronaut
    It's all about that 'Location' header.
  6. #6
    Soyboy IV: The Flower of Death and The Crystal of Life African Astronaut [the oppositely able-bodied hop-step-and-jump]
    Originally posted by esbity It's all about that 'Location' header.

    How can I get that header without downloading the whole podcast file? These can be 3 hour podcasts, 150mb easy, and I'd like to do everything on the client side.
  7. #7
    esbity African Astronaut
    Originally posted by MORALLY SUPERIOR BEING IV: The Flower of Death and The Crystal of Life How can I get that header without downloading the whole podcast file? These can be 3 hour podcasts, 150mb easy, and I'd like to do everything on the client side.

    Send a HEAD request.
    The following users say it would be alright if the author of this post didn't die in a fire!
  8. #8
    Dfg Tuskegee Airman [compulsively riposte the emigrant]
    thanks for the link, it looks cool. However it only works in Chrome 71 or higher, wouldn't it be smarter to have something that works on other browsers? or has a fall back?
  9. #9
    Soyboy IV: The Flower of Death and The Crystal of Life African Astronaut [the oppositely able-bodied hop-step-and-jump]
    Originally posted by Dfg thanks for the link, it looks cool. However it only works in Chrome 71 or higher, wouldn't it be smarter to have something that works on other browsers? or has a fall back?

    Yes, it's going to have a fallback. Background Fetch is only interesting as an alternative to Fetch as it provides a way to download things without as much risk of the service worker getting shoahed as a result, but if background fetch isn't available in the browser then I'll try to use normal fetch instead.

    There actually appears to be a fallback method specified in the original source code, but it doesn't seem to work, not sure why.
    https://glitch.com/edit/#!/bgfetch-http203?path=public/client.js:209:28
  10. #10
    Soyboy IV: The Flower of Death and The Crystal of Life African Astronaut [the oppositely able-bodied hop-step-and-jump]
    OK balls deep on this fallback method, I'm trying to figure out fetch with both progress and abort controllers, but it's really hard and I'm getting discouraged. Half the problem is that I haven't found any decent docs on fetching binaries/blobs or whatever an mp3 file is.

    On top of everything else I can't be sure that the problem isn't with libsyn/the remote server.

    Any tips would be appreciated. Is response.body the wrong place to be looking for an mp3 file? What about Response objects? What about readstreams?

    I've tried googling, but haven't found anything interesting with all three aspects of functionality.

    I'll probably just skip it all and move on to trying to make a server that accepts mp3s and descriptions and "syndicates" them by RSS.

    Also need to make the mp3 file download in it's entirety once playback starts, and remember the playback position.

    Lol, feeling overwhelmed right now.
  11. #11
    esbity African Astronaut
    What is the IP address of this server? And what is the URL your requesting?
  12. #12
    Soyboy IV: The Flower of Death and The Crystal of Life African Astronaut [the oppositely able-bodied hop-step-and-jump]
    Originally posted by esbity What is the IP address of this server? And what is the URL your requesting?

    I dunno what the ip is, don't need it. It's just various libsyn podcast feeds.
  13. #13
    Soyboy IV: The Flower of Death and The Crystal of Life African Astronaut [the oppositely able-bodied hop-step-and-jump]
    Originally posted by esbity Send a HEAD request.

    Libsyn doesn't seem to provide any redirect url in headers although they probably should. They are using a 302 redirect by the way.

    I'll probably just finish this project with fetch alone for now.
Jump to Top