What does abContent() do?

Asked by qianguozheng on 2016-04-12

Below is the adapter_modifying working process means api call procedure, I know the construct and destruct function calls, but the others detail I cannot tell apart from each other.

could anyone help me on that ?

adapter_modifying: Adapter::Xaction::Xaction() -- Construt function
adapter_modifying: Adapter::Xaction::start()
adapter_modifying: Adapter::Xaction::abMake()
adapter_modifying: Adapter::Xaction::noteVbContentAvailable()
adapter_modifying: adaptContent()
adapter_modifying: Adapter::Xaction::abContent(size_type offset, size_type size)
adapter_modifying: Adapter::Xaction::abContentShift(size_type size)
adapter_modifying: Adapter::Xaction::noteVbContentDone(bool atEnd)
adapter_modifying: Adapter::Xaction::stopVb()
adapter_modifying: Adapter::Xaction::abContent(size_type offset, size_type size)
adapter_modifying: Adapter::Xaction::stop()
adapter_modifying: Adapter::Xaction::~Xaction() -- Destruct function

what abContent() method doing, why it is called twice ?

Question information

English Edit question
eCAP Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:

This question was reopened

Alex Rousskov (rousskov) said : #1

> what abContent() method doing

The method gives adapted body (ab) bytes to the host application. The host application specifies how many bytes it wants, starting from the first available byte after the abContentShift() call (or from the very first body byte if there has been no abContentShift() calls yet).

> why it is called twice?

There can be many reasons, including:

1. The host application wanted to check whether the adapter made more ab content after the last abContent() call.
2. The host application did not have enough buffer space to copy the entire available ab content during the first call.
3. The host application does not optimize unnecessary abContent() calls away (i.e., calls abContent() more often than is strictly necessary).

Your adapter should handle abContent() calls correctly in all these and other cases. I do not recommend assuming much about the host application behavior in this context.

Alex Rousskov (rousskov) said : #2

> starting from the first available byte...

That was misleading. The abContent() offset parameter is relative to the first available byte... In most cases, the host application will use zero offset parameter to mean "the first available byte..." but it does not have to.



I still have a problem, I buffer the gzip stream in noteVbContentAvailable() method, and in noteVbContentDone(bool atEnd) decompress gzip stream, after that, what should I do to send the decompressed data to host-side ?

Alex Rousskov (rousskov) said : #4

See https://answers.launchpad.net/ecap/+question/255988 for hints about sending adapted bodies to the host application.

Thanks Alex, I found that my mistake is the Content-Encoding not removed from response headers.