Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem when action request doesn't have Content-Length header
01-07-2013, 08:24 PM
Post: #4
RE: Problem when action request doesn't have Content-Length header
(01-07-2013 04:04 PM)simonc Wrote:  It might take me slightly longer to get this integrated. To aid native embedded clients with tight memory budgets, device stack code is often stricter than control point code about use of dynamic allocation. This means that patterns which are suitable for control point development aren't always appropriate on device side.

I'd like to find a way to implement this functionality without the dynamic per-action allocation. Its not immediately obvious how to do this so it might take me a couple of days to work through.

I can see a simple improvement to my patch that would eliminate dynamic allocation for the normal case where Content-Length is specified.

Code:
TUint length = iHeaderContentLength.ContentLength();
if (length != 0) {
    iSoapRequest.Set(iReadBuffer->Read(length));
}
else {
    Bwh entity;
    if (iHeaderTransferEncoding.IsChunked()) {
        ReaderHttpChunked dechunker(*iReadBuffer);
        dechunker.Read();
        dechunker.TransferTo(entity);
    }
    else { // read until connection closed by control point
        try {
            for (;;) {
                Brn buf = iReadBuffer->Read(kMaxRequestBytes);
                entity.Grow(entity.Bytes() + kMaxRequestBytes);
                entity.Append(buf);
            }
        }
        catch (ReaderError&) {
            Brn snaffle = iReadBuffer->Snaffle();
            entity.Grow(entity.Bytes() + snaffle.Bytes());
            entity.Append(snaffle);
        }
    }
    iSoapRequest.Set(entity);
}

As you say, it is harder to see how to eliminate dynamic allocation for the other two cases (which should not occur with most control points).
Find all posts by this user


Messages In This Thread
RE: Problem when action request doesn't have Content-Length header - simoncn - 01-07-2013 08:24 PM

Forum Jump: