--- /dev/null
+/*
+ * DEBUG: section XXX
+ */
+
+#include "squid.h"
+#include "HttpMsg.h"
+#include "TextException.h"
+#include "adaptation/Message.h"
+
+Adaptation::Message::Message(): header(NULL)
+{
+}
+
+Adaptation::Message::Message(Header *aHeader): header(NULL)
+{
+ set(aHeader);
+}
+
+Adaptation::Message::~Message()
+{
+ clear();
+}
+
+void
+Adaptation::Message::clear()
+{
+ HTTPMSGUNLOCK(header);
+ body_pipe = NULL;
+}
+
+void
+Adaptation::Message::set(Header *aHeader)
+{
+ clear();
+ if (aHeader) {
+ header = HTTPMSGLOCK(aHeader);
+ body_pipe = header->body_pipe;
+ }
+}
+
+void
+Adaptation::Message::copyTo(Message &dest)
+{
+ Must(!dest.body_pipe); // can relax if needed, but need !body_pipe->used()
+ dest.clear();
+ if (header) {
+ if (header->body_pipe != NULL) {
+ // check that it would not be too late to clone the pipe
+ Must(!header->body_pipe->consumedSize());
+ header->body_pipe->clearConsumer(); // if any
+ // note: current header->body_pipe producer may later become
+ // dest.body_pipe consumer and consume its own data
+ // TODO: consumer should detect and short-circuit no-op adaptation
+ }
+ Header *copy = header->clone();
+ dest.set(copy);
+ }
+}
--- /dev/null
+
+/*
+ * $Id$
+ */
+
+#ifndef SQUID__ADAPTATION__MESSAGE_H
+#define SQUID__ADAPTATION__MESSAGE_H
+
+class HttpMsg;
+class BodyPipe;
+template <class C>
+class RefCount;
+typedef RefCount<BodyPipe> BodyPipePointer;
+
+namespace Adaptation {
+
+// Manages the header and the body of an HTTP message being worked on.
+// Adaptation transactions use this class for virgin and adapted HTTP messages.
+class Message
+{
+
+public:
+ typedef HttpMsg Header;
+
+ Message();
+ Message(Header *aHeader);
+ ~Message();
+
+ void clear();
+ void set(Header *aHeader);
+
+ void copyTo(Message &dest);
+
+public:
+ // virgin or adapted message being worked on
+ Header *header; // parsed HTTP status/request line and headers
+
+ // Copy of header->body_pipe, in case somebody moves the original.
+ BodyPipePointer body_pipe;
+
+private:
+ Message(const Message &); // not implemented
+ Message &operator =(const Message &); // not implemented
+};
+
+} // namespace Adaptation;
+
+// TODO: replace ICAPInOut with Adaptation::Message (adding one for "cause")
+
+#endif /* SQUID__ADAPTATION__MESSAGE_H */