The HTTP implementation depends on CURL and would preferably not be part of the LLVM dylib. This was not possible as a nested library under libSupport, because libSupport itself is part of the LLVM dylib. This patch moves the HTTP code into a separate top-level library that is independent from libSupport and excluded from the LLVM dylib.
35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/HTTP/StreamedHTTPResponseHandler.h"
|
|
|
|
namespace llvm {
|
|
|
|
Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
|
|
if (!FileStream) {
|
|
unsigned Code = Client.responseCode();
|
|
if (Code && Code != 200)
|
|
return Error::success();
|
|
Expected<std::unique_ptr<CachedFileStream>> FileStreamOrError =
|
|
CreateStream();
|
|
if (!FileStreamOrError)
|
|
return FileStreamOrError.takeError();
|
|
FileStream = std::move(*FileStreamOrError);
|
|
}
|
|
*FileStream->OS << BodyChunk;
|
|
return Error::success();
|
|
}
|
|
|
|
Error StreamedHTTPResponseHandler::commit() {
|
|
if (FileStream)
|
|
return FileStream->commit();
|
|
return Error::success();
|
|
}
|
|
|
|
} // namespace llvm
|