mirror of https://github.com/Xhofe/alist
				
				
				
			* fix(mopan):302 Redirect * fix(mopan): do not forget to close the body --------- Co-authored-by: Andy Hsu <i@nn.ci>pull/5519/head
							parent
							
								
									91f51f17d0
								
							
						
					
					
						commit
						55a14bc271
					
				| 
						 | 
				
			
			@ -119,10 +119,13 @@ func (d *MoPan) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	data.DownloadUrl = strings.Replace(strings.ReplaceAll(data.DownloadUrl, "&", "&"), "http://", "https://", 1)
 | 
			
		||||
	res, err := base.NoRedirectClient.R().SetContext(ctx).Head(data.DownloadUrl)
 | 
			
		||||
	res, err := base.NoRedirectClient.R().SetDoNotParseResponse(true).SetContext(ctx).Get(data.DownloadUrl)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	defer func() {
 | 
			
		||||
		_ = res.RawBody().Close()
 | 
			
		||||
	}()
 | 
			
		||||
	if res.StatusCode() == 302 {
 | 
			
		||||
		data.DownloadUrl = res.Header().Get("location")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue