--- a/servlib/bundling/BPQResponse.cc Fri May 27 18:33:25 2011 +0100
+++ b/servlib/bundling/BPQResponse.cc Mon May 30 19:36:18 2011 +0100
@@ -65,10 +65,6 @@
new_bi->set_flag(current.flags());
new_response->api_blocks()->append_block(current.owner(), new_bi);
-
- if (new_bi->type()==200){
- log_debug_p(LOG, "_FOO_ new_bi->contents(): watch %p",&(new_bi->contents()));
- }
}
// copy RECV blocks
@@ -84,14 +80,61 @@
new_bi->set_flag(current.flags());
new_response->mutable_recv_blocks()->append_block(current.owner(), new_bi);
-
- if (new_bi->type()==200){
- log_debug_p(LOG, "_FOO_ new_bi->contents(): watch %p",&(new_bi->contents()));
+ if (new_bi->type() == 200) {
+ BPQBlock bpq(new_bi);
+ log_debug_p(LOG, "_COPY_ kind(%d) query_len(%d) query(%s)",
+ bpq.kind(), bpq.query_len(), bpq.query_val());
}
-
}
return true;
}
+bool
+BPQResponse::copy_bpq_response(Bundle* new_response,
+ Bundle* response)
+{
+ log_debug_p(LOG, "BPQResponse::copy_bpq_response");
+
+ // init metadata
+ response->copy_metadata(new_response);
+
+ // set payload
+ log_debug_p(LOG, "Copy response payload");
+ new_response->mutable_payload()->
+ replace_with_file(response->payload().filename().c_str());
+
+ // copy API blocks
+ BlockInfoVec* api_blocks = response->api_blocks();
+
+ for (BlockInfoVec::iterator iter = api_blocks->begin();
+ iter != api_blocks->end();
+ ++iter)
+ {
+ BlockInfo current = *iter;
+
+ BlockInfo* new_bi = new BlockInfo(current);
+ new_bi->set_flag(current.flags());
+
+ new_response->api_blocks()->append_block(current.owner(), new_bi);
+ }
+
+ // copy RECV blocks
+ BlockInfoVec* recv_blocks = response->mutable_recv_blocks();
+
+ for (BlockInfoVec::iterator iter = recv_blocks->begin();
+ iter != recv_blocks->end();
+ ++iter)
+ {
+ BlockInfo current = *iter;
+
+ BlockInfo* new_bi = new BlockInfo(current);
+ new_bi->set_flag(current.flags());
+
+ new_response->mutable_recv_blocks()->append_block(current.owner(), new_bi);
+ }
+
+ return true;
+}
+
} // namespace dtn