LLVM 23.0.0git
StreamedHTTPResponseHandler.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11namespace llvm {
12
14 if (!FileStream) {
15 unsigned Code = Client.responseCode();
16 if (Code && Code != 200)
17 return Error::success();
19 CreateStream();
20 if (!FileStreamOrError)
21 return FileStreamOrError.takeError();
22 FileStream = std::move(*FileStreamOrError);
23 }
24 *FileStream->OS << BodyChunk;
25 return Error::success();
26}
27
29 if (FileStream)
30 return FileStream->commit();
31 return Error::success();
32}
33
34} // namespace llvm
An HTTPResponseHandler that streams the response body to a CachedFileStream.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
Error takeError()
Take ownership of the stored error.
Definition Error.h:612
Error commit()
Must be called exactly once after the writes have been completed but before the StreamedHTTPResponseH...
Error handleBodyChunk(StringRef BodyChunk) override
Processes an additional chunk of bytes of the HTTP response body.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.