}
void
-Adaptation::Message::copyTo(Message &dest)
+Adaptation::Message::ShortCircuit(Message &src, 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);
+ Must(!dest.header); // the message is not "used"
+ Must(!dest.body_pipe); // can relax if needed, but need !body_pipe->used()
+ Must(src.header); // or there is nothing to shortcircuit
+
+ if (src.header->body_pipe != NULL) {
+ // check that it would not be too late to shortcircuit the pipe
+ Must(!src.header->body_pipe->consumedSize());
+ src.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 bypass short-circuit adaptation
}
+ dest.set(src.header->clone());
}
// Manages the header and the body of an HTTP message being worked on.
// Adaptation transactions use this class for virgin and adapted HTTP messages.
+// TODO: remove this class after adding refcounted message pointers and
+// after making sure nobody abruptly clears the HttpMsg::body_pipe pointer.
class Message
{
void clear();
void set(Header *aHeader);
- void copyTo(Message &dest);
+ static void ShortCircuit(Message &src, Message &dest);
public:
// virgin or adapted message being worked on