]> granicus.if.org Git - icinga2/commitdiff
Quality: Removed unused HttpChunkedEncoding class
authorMichael Friedrich <michael.friedrich@icinga.com>
Tue, 28 May 2019 11:46:19 +0000 (13:46 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 28 May 2019 11:46:19 +0000 (13:46 +0200)
lib/remote/CMakeLists.txt
lib/remote/httpchunkedencoding.cpp [deleted file]
lib/remote/httpchunkedencoding.hpp [deleted file]

index bd088487618740ea16dd88724dfa6a8569c216da..da0006aa19e14fe9e0528c145c7ba68924a590bd 100644 (file)
@@ -25,7 +25,6 @@ set(remote_SOURCES
   eventqueue.cpp eventqueue.hpp
   eventshandler.cpp eventshandler.hpp
   filterutility.cpp filterutility.hpp
-  httpchunkedencoding.cpp httpchunkedencoding.hpp
   httphandler.cpp httphandler.hpp
   httpserverconnection.cpp httpserverconnection.hpp
   httputility.cpp httputility.hpp
diff --git a/lib/remote/httpchunkedencoding.cpp b/lib/remote/httpchunkedencoding.cpp
deleted file mode 100644 (file)
index 2b52636..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
-
-#include "remote/httpchunkedencoding.hpp"
-#include <sstream>
-
-using namespace icinga;
-
-StreamReadStatus HttpChunkedEncoding::ReadChunkFromStream(const Stream::Ptr& stream,
-       char **data, size_t *size, ChunkReadContext& context, bool may_wait)
-{
-       if (context.LengthIndicator == -1) {
-               String line;
-               StreamReadStatus status = stream->ReadLine(&line, context.StreamContext, may_wait);
-               may_wait = false;
-
-               if (status != StatusNewItem)
-                       return status;
-
-               std::stringstream msgbuf;
-               msgbuf << std::hex << line;
-               msgbuf >> context.LengthIndicator;
-
-               if (context.LengthIndicator < 0)
-                       BOOST_THROW_EXCEPTION(std::invalid_argument("HTTP chunk length must not be negative."));
-       }
-
-       StreamReadContext& scontext = context.StreamContext;
-       if (scontext.Eof)
-               return StatusEof;
-
-       if (scontext.MustRead) {
-               if (!scontext.FillFromStream(stream, may_wait)) {
-                       scontext.Eof = true;
-                       return StatusEof;
-               }
-
-               scontext.MustRead = false;
-       }
-
-       size_t NewlineLength = context.LengthIndicator ? 2 : 0;
-
-       if (scontext.Size < (size_t)context.LengthIndicator + NewlineLength) {
-               scontext.MustRead = true;
-               return StatusNeedData;
-       }
-
-       *data = new char[context.LengthIndicator];
-       *size = context.LengthIndicator;
-       memcpy(*data, scontext.Buffer, context.LengthIndicator);
-
-       scontext.DropData(context.LengthIndicator + NewlineLength);
-       context.LengthIndicator = -1;
-
-       return StatusNewItem;
-}
-
-void HttpChunkedEncoding::WriteChunkToStream(const Stream::Ptr& stream, const char *data, size_t count)
-{
-       std::ostringstream msgbuf;
-       msgbuf << std::hex << count << "\r\n";
-       String lengthIndicator = msgbuf.str();
-       stream->Write(lengthIndicator.CStr(), lengthIndicator.GetLength());
-       stream->Write(data, count);
-       if (count > 0)
-               stream->Write("\r\n", 2);
-}
diff --git a/lib/remote/httpchunkedencoding.hpp b/lib/remote/httpchunkedencoding.hpp
deleted file mode 100644 (file)
index 70cd58c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
-
-#ifndef HTTPCHUNKEDENCODING_H
-#define HTTPCHUNKEDENCODING_H
-
-#include "remote/i2-remote.hpp"
-#include "base/stream.hpp"
-
-namespace icinga
-{
-
-struct ChunkReadContext
-{
-       StreamReadContext& StreamContext;
-       int LengthIndicator;
-
-       ChunkReadContext(StreamReadContext& scontext)
-               : StreamContext(scontext), LengthIndicator(-1)
-       { }
-};
-
-/**
- * HTTP chunked encoding.
- *
- * @ingroup remote
- */
-struct HttpChunkedEncoding
-{
-       static StreamReadStatus ReadChunkFromStream(const Stream::Ptr& stream,
-               char **data, size_t *size, ChunkReadContext& ccontext, bool may_wait = false);
-       static void WriteChunkToStream(const Stream::Ptr& stream, const char *data, size_t count);
-
-};
-
-}
-
-#endif /* HTTPCHUNKEDENCODING_H */