mirror of
				https://github.com/rust-lang/cargo.git
				synced 2025-11-03 13:12:53 +00:00 
			
		
		
		
	Auto merge of #13158 - Turbo87:crates-io-status-codes, r=epage
crates-io: Add support for other 2xx HTTP status codes Replying with `201 Created` of `202 Accepted` should not result in showing errors. Related: - https://github.com/rust-lang/cargo/issues/3995 - https://github.com/rust-lang/cargo/pull/6771
This commit is contained in:
		
						commit
						1aa9df1a5b
					
				@ -436,7 +436,8 @@ impl Registry {
 | 
			
		||||
            .map(|s| s.errors.into_iter().map(|s| s.detail).collect::<Vec<_>>());
 | 
			
		||||
 | 
			
		||||
        match (self.handle.response_code()?, errors) {
 | 
			
		||||
            (0, None) | (200, None) => Ok(body),
 | 
			
		||||
            (0, None) => Ok(body),
 | 
			
		||||
            (code, None) if is_success(code) => Ok(body),
 | 
			
		||||
            (code, Some(errors)) => Err(Error::Api {
 | 
			
		||||
                code,
 | 
			
		||||
                headers,
 | 
			
		||||
@ -451,8 +452,12 @@ impl Registry {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn is_success(code: u32) -> bool {
 | 
			
		||||
    code >= 200 && code < 300
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn status(code: u32) -> String {
 | 
			
		||||
    if code == 200 {
 | 
			
		||||
    if is_success(code) {
 | 
			
		||||
        String::new()
 | 
			
		||||
    } else {
 | 
			
		||||
        let reason = reason(code);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user