fix testcase TestReadStreamWithOffset incompatible with oss
Signed-off-by: tgic <farmer1992@gmail.com>master
							parent
							
								
									2a8535626f
								
							
						
					
					
						commit
						8e5c901a26
					
				| 
						 | 
					@ -276,12 +276,18 @@ func (d *driver) ReadStream(ctx context.Context, path string, offset int64) (io.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp, err := d.Bucket.GetResponseWithHeaders(d.ossPath(path), headers)
 | 
						resp, err := d.Bucket.GetResponseWithHeaders(d.ossPath(path), headers)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if ossErr, ok := err.(*oss.Error); ok && ossErr.Code == "InvalidRange" {
 | 
							return nil, parseError(path, err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Due to Aliyun OSS API, status 200 and whole object will be return instead of an
 | 
				
			||||||
 | 
						// InvalidRange error when range is invalid.
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// OSS sever will always return http.StatusPartialContent if range is acceptable.
 | 
				
			||||||
 | 
						if resp.StatusCode != http.StatusPartialContent {
 | 
				
			||||||
 | 
							resp.Body.Close()
 | 
				
			||||||
		return ioutil.NopCloser(bytes.NewReader(nil)), nil
 | 
							return ioutil.NopCloser(bytes.NewReader(nil)), nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return nil, parseError(path, err)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return resp.Body, nil
 | 
						return resp.Body, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue