4#ifndef _Stroika_Framework_WebServer_Response_h_
5#define _Stroika_Framework_WebServer_Response_h_ 1
7#include "Stroika/Frameworks/StroikaPreComp.h"
14#include "Stroika/Foundation/Common/Common.h"
15#include "Stroika/Foundation/Common/Property.h"
17#include "Stroika/Foundation/Cryptography/Digest/Digester.h"
21#include "Stroika/Foundation/IO/Network/HTTP/Headers.h"
22#include "Stroika/Foundation/IO/Network/HTTP/Response.h"
23#include "Stroika/Foundation/IO/Network/HTTP/Status.h"
29#include "Stroika/Foundation/Streams/SharedMemoryStream.h"
100 Response () =
delete;
101 Response (
const Response&) =
delete;
102 Response (Response&& src);
104 const optional<HTTP::Headers>& initialHeaders = nullopt);
110 ~Response () =
default;
113 nonvirtual Response& operator= (
const Response&) =
delete;
114 nonvirtual Response& operator= (Response&&) noexcept;
124 Common::Property<
bool> autoComputeETag;
152 Common::Property<optional<
size_t>> automaticTransferChunkSize;
158 static constexpr
size_t kNoChunkedTransfer = numeric_limits<
size_t>::max ();
167 static constexpr
size_t kAutomaticTransferChunkSize_Default = 16 * 1024;
179 Common::Property<optional<HTTP::ContentEncodings>> bodyEncoding;
189 Common::ReadOnlyProperty<
bool> chunkedTransferMode;
198 Common::ReadOnlyProperty<Characters::CodeCvt<>> codeCvt;
221 Common::Property<Characters::CodePage> codePage;
233 Common::Property<optional<InternetMediaType>> contentType;
245 Common::ReadOnlyProperty<
bool> hasEntityBody;
255 Common::ReadOnlyProperty<
bool> headersCanBeSet;
263 Common::Property<
bool> headMode;
269 Common::Property<optional<
URI>> location;
276 Common::ReadOnlyProperty<
bool> responseAborted;
283 Common::ReadOnlyProperty<
bool> responseCompleted;
290 Common::ReadOnlyProperty<
bool> responseStatusSent;
300 enum class State : uint8_t {
330 nonvirtual
void Flush ();
347 nonvirtual
bool End ();
357 nonvirtual
void Abort ();
366 nonvirtual
void Redirect (
const URI& url);
380 nonvirtual
void write (
const span<const byte>& b);
381 nonvirtual
void write (
const TypedBLOB& b);
382 template <Characters::IConvertibleToString T>
383 nonvirtual
void write (T&& s);
384 template <
typename CHAR_T,
typename... ARGS>
385 nonvirtual
void write (
const FormatString<CHAR_T>& f, ARGS&&... args);
389 template <
typename T>
390 nonvirtual
void Write (T t)
397 template <
typename T>
398 nonvirtual
void WriteLn (T t)
408 nonvirtual
void writeln (
const String& e);
417 nonvirtual
void FlushNextChunkIfNeeded_ ();
420 nonvirtual
void StateTransition_ (State to);
423 nonvirtual
void ApplyBodyEncodingIfNeeded_ ();
429 nonvirtual
void WriteChunk_ (span<const byte> rawBytes);
432 nonvirtual InternetMediaType AdjustContentTypeForCodePageIfNeeded_ (
const InternetMediaType& ct)
const;
440#if !qCompilerAndStdLib_enum_with_bitLength_opequals_Buggy
441 State fState_ : 3 {State::ePreparingHeaders};
442 bool fHeadMode_ : 1 {
false};
443 bool fAborted_ : 1 {
false};
445 State fState_{State::ePreparingHeaders};
446 bool fHeadMode_{
false};
447 bool fAborted_{
false};
449 optional<size_t> fAutoTransferChunkSize_{nullopt};
450 optional<HTTP::ContentEncodings> fBodyEncoding_;
452 size_t fBodyRawStreamLength_{};
453 size_t fBodyRowStreamLengthWhenLastChunkGenerated_{};
457 mutable optional<Characters::CodeCvt<>> fCodeCvt_;
458 optional<ETagDigester_> fETagDigester_;
461 [[deprecated (
"Since Stroika v3.0d6 - use write with _f strings")]]
void printf (
const wchar_t* format, ...);
462 [[deprecated (
"Since Stroika v3.0d7 use span overload)")]]
void write (
const byte* s,
const byte* e)
465 write (span<const byte>{s, e});
467 [[deprecated (
"Since Stroika v3.0d6 - use write with _f strings")]]
void write (
const wchar_t* s,
const wchar_t* e)
469 write (span<const wchar_t>{s, e});
473 void Response::write (
const String& e);
482#include "Response.inl"
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)
String is like std::u32string, except it is much easier to use, often much more space efficient,...
IncrementalDigester<ALGORITHM> () is the low level way to call Digest algorithms, appropriate for str...
TypedBLOB is a named tuple<Memory::BLOB, optional<InternetMediaType>> - with friendlier names,...
a smart pointer wrapper (like shared_ptr <_IRep>).
OutputStream<>::Ptr is Smart pointer to a stream-based sink of data.
STRING_TYPE ToString(FLOAT_TYPE f, const ToStringOptions &options={})
CONTAINER::value_type * End(CONTAINER &c)
For a contiguous container (such as a vector or basic_string) - find the pointer to the end of the co...
void Abort(const Traversal::Iterable< Ptr > &threads)
foreach Thread t: t.Abort ()