mirror of
				https://github.com/TeamPiped/piped-proxy.git
				synced 2024-08-14 23:50:45 +00:00 
			
		
		
		
	Only attempt ump decoding when response is successful.
This commit is contained in:
		
							parent
							
								
									000a14e738
								
							
						
					
					
						commit
						e0bb6a3a78
					
				
					 1 changed files with 3 additions and 4 deletions
				
			
		| 
						 | 
					@ -464,9 +464,7 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
 | 
				
			||||||
        response.no_chunking(content_length.to_str().unwrap().parse::<u64>().unwrap());
 | 
					        response.no_chunking(content_length.to_str().unwrap().parse::<u64>().unwrap());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let resp = resp.bytes_stream();
 | 
					    if is_ump && resp.status().is_success() {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if is_ump {
 | 
					 | 
				
			||||||
        if let Some(mime_type) = mime_type {
 | 
					        if let Some(mime_type) = mime_type {
 | 
				
			||||||
            response.content_type(mime_type);
 | 
					            response.content_type(mime_type);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -480,6 +478,7 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        let resp = resp.bytes_stream();
 | 
				
			||||||
        let resp = resp.map_err(|e| io::Error::new(ErrorKind::Other, e));
 | 
					        let resp = resp.map_err(|e| io::Error::new(ErrorKind::Other, e));
 | 
				
			||||||
        let transformed_stream = UmpTransformStream::new(resp);
 | 
					        let transformed_stream = UmpTransformStream::new(resp);
 | 
				
			||||||
        // print errors
 | 
					        // print errors
 | 
				
			||||||
| 
						 | 
					@ -506,5 +505,5 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Stream response
 | 
					    // Stream response
 | 
				
			||||||
    Ok(response.streaming(resp))
 | 
					    Ok(response.streaming(resp.bytes_stream()))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue