Add support for rar extraction

This commit is contained in:
Ben Adrian Sarmiento
2024-06-05 09:20:40 +02:00
parent f977abc052
commit 62e6143e06
9 changed files with 112 additions and 46 deletions

View File

@@ -328,20 +328,10 @@ func (r *HTTPClient) CanFetchFirstByte(url string) bool {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
req = req.WithContext(ctx)
resp, err := r.Do(req)
if err != nil {
return false
}
defer resp.Body.Close()
// If server supports partial content
if resp.StatusCode/100 == 2 {
buffer := make([]byte, 1)
_, err = resp.Body.Read(buffer)
if err == nil {
return true
}
resp, _ := r.Do(req)
if resp != nil {
defer resp.Body.Close()
return resp.StatusCode == 200 || resp.StatusCode == 206
}
return false
}