File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
tensorflow/core/platform/cloud Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -383,15 +383,18 @@ Status HttpRequest::Send() {
383
383
return Status::OK ();
384
384
case 401 :
385
385
case 403 :
386
+ response_buffer_->clear ();
386
387
return errors::PermissionDenied (error_message);
387
388
case 404 :
389
+ response_buffer_->clear ();
388
390
return errors::NotFound (error_message);
389
391
case 416 : // Requested Range Not Satisfiable
390
392
response_buffer_->clear ();
391
393
return Status::OK ();
392
394
default :
393
395
// UNAVAILABLE can be retried by the caller, e.g by
394
396
// RetryingFileSystem.
397
+ response_buffer_->clear ();
395
398
return errors::Unavailable (error_message);
396
399
}
397
400
}
Original file line number Diff line number Diff line change @@ -528,5 +528,24 @@ TEST(HttpRequestTest, EscapeString) {
528
528
EXPECT_EQ (" a%2Fb%2Fc" , http_request.EscapeString (test_string));
529
529
}
530
530
531
+ TEST (HttpRequestTest, ErrorReturnsNoResponse) {
532
+ FakeLibCurl libcurl (" get response" , 500 );
533
+ HttpRequest http_request (&libcurl);
534
+ TF_EXPECT_OK (http_request.Init ());
535
+
536
+ std::vector<char > scratch;
537
+ scratch.insert (scratch.begin (), kTestContent .begin (), kTestContent .end ());
538
+ StringPiece result;
539
+ scratch.reserve (100 );
540
+
541
+ TF_EXPECT_OK (http_request.SetUri (" http://www.testuri.com" ));
542
+ TF_EXPECT_OK (http_request.AddAuthBearerHeader (" fake-bearer" ));
543
+ TF_EXPECT_OK (http_request.SetRange (100 , 199 ));
544
+ TF_EXPECT_OK (http_request.SetResultBuffer (&scratch));
545
+ EXPECT_EQ (error::UNAVAILABLE, http_request.Send ().code ());
546
+
547
+ EXPECT_EQ (" " , string (scratch.begin (), scratch.end ()));
548
+ }
549
+
531
550
} // namespace
532
551
} // namespace tensorflow
You can’t perform that action at this time.
0 commit comments