aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/client/fetch/fetch_result.cpp
blob: 0ba1b1e6becc2e2c150e7adac5c8a488872489ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "codes.h"
#include "fetch_result.h"

#include <library/cpp/charset/recyr.hh>

namespace NHttpFetcher {
    TResult::TResult(const TString& url, int code)
        : RequestUrl(url)
        , ResolvedUrl(url)
        , Code(code)
        , ConnectionReused(false)
    {
    }

    TString TResult::DecodeData(bool* decoded) const {
        if (!!Encoding && *Encoding != CODES_UTF8) {
            if (decoded) {
                *decoded = true;
            }
            return Recode(*Encoding, CODES_UTF8, Data);
        }
        if (decoded) {
            *decoded = false;
        }
        return Data;
    }

    bool TResult::Success() const {
        return Code == FETCH_SUCCESS_CODE;
    }

}