packwiz / packwiz-installer

An installer for packwiz modpacks, with automatic auto-updating and optional mods! Works well with MultiMC and on servers.
https://packwiz.infra.link/
MIT License
46 stars 21 forks source link

Follow redirect locations when resolving "child" requests #43

Open rhullah opened 1 year ago

rhullah commented 1 year ago

Description

If a parent HTTP request returns a redirect respose, subsequent child requests should respect the redirect location from parent's response.

Parent Request Child Request
pack.toml [index].file
index.toml [[files]].file

Example

Parent Request for pack.toml: GET http://myserver/v1.19/pack.toml

> GET /v1.19/pack.toml
> HOST: myserver

< HTTP/1.1 301 Moved Permanently
< Location: http://myserver/v1.19.0/pack.toml

Expected Behavior:

With the example request/response above packwiz-installer should make subsequent child requests relative to the redirect response: Child Index Request: http://myserver/v1.19.0/index.toml

Actual Behavior:

The current implementation makes subsequent child requests relative to original Parent pack.toml request: Child Index Request: http://myserver/v1.19/index.toml


Fix on Web Server side:

I know that a simple fix for this is to setup a server-side redirect/rewrite for everything in the directory (/v1.19/* in the example), but packwiz-installer should respect location changes so that it's not constantly getting redirects responses.