summaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/http/http.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'yt/cpp/mapreduce/http/http.cpp')
-rw-r--r--yt/cpp/mapreduce/http/http.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/yt/cpp/mapreduce/http/http.cpp b/yt/cpp/mapreduce/http/http.cpp
index e6efaa9d637..188f6e80281 100644
--- a/yt/cpp/mapreduce/http/http.cpp
+++ b/yt/cpp/mapreduce/http/http.cpp
@@ -29,6 +29,7 @@
#include <util/system/getpid.h>
#include <exception>
+#include <memory>
namespace NYT {
@@ -115,7 +116,7 @@ private:
}
// In many cases http proxy stops reading request and resets connection
- // if error has happend. This function tries to read error response
+ // if error has happened. This function tries to read error response
// in such cases.
void HandleWriteException(const std::exception& ex) {
Y_ABORT_UNLESS(WriteError_ == nullptr);
@@ -698,34 +699,40 @@ class THttpResponse::THttpInputWrapped
public:
explicit THttpInputWrapped(TRequestContext context, IInputStream* input)
: Context_(std::move(context))
- , HttpInput_(input)
- { }
+ {
+ try {
+ HttpInput_ = std::make_unique<THttpInput>(input);
+ } catch (const std::exception& ex) {
+ auto wrapped = WrapSystemError(Context_, ex);
+ std::rethrow_exception(wrapped);
+ }
+ }
const THttpHeaders& Headers() const noexcept
{
- return HttpInput_.Headers();
+ return HttpInput_->Headers();
}
const TString& FirstLine() const noexcept
{
- return HttpInput_.FirstLine();
+ return HttpInput_->FirstLine();
}
bool IsKeepAlive() const noexcept
{
- return HttpInput_.IsKeepAlive();
+ return HttpInput_->IsKeepAlive();
}
const TMaybe<THttpHeaders>& Trailers() const noexcept
{
- return HttpInput_.Trailers();
+ return HttpInput_->Trailers();
}
private:
size_t DoRead(void* buf, size_t len) override
{
try {
- return HttpInput_.Read(buf, len);
+ return HttpInput_->Read(buf, len);
} catch (const std::exception& ex) {
auto wrapped = WrapSystemError(Context_, ex);
std::rethrow_exception(wrapped);
@@ -735,7 +742,7 @@ private:
size_t DoSkip(size_t len) override
{
try {
- return HttpInput_.Skip(len);
+ return HttpInput_->Skip(len);
} catch (const std::exception& ex) {
auto wrapped = WrapSystemError(Context_, ex);
std::rethrow_exception(wrapped);
@@ -744,7 +751,7 @@ private:
private:
const TRequestContext Context_;
- THttpInput HttpInput_;
+ std::unique_ptr<THttpInput> HttpInput_;
};
THttpResponse::THttpResponse(