From 8888c5ae47209d1fe07de62bf51928d26d786fa4 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 5 Jul 2011 18:29:55 +0300 Subject: [PATCH] gobex: Fix end of body packets for on-demand headers --- gobex/gobex-packet.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c index 16d4b7a77..e5bf618ac 100644 --- a/gobex/gobex-packet.c +++ b/gobex/gobex-packet.c @@ -290,6 +290,15 @@ gssize g_obex_packet_encode(GObexPacket *pkt, guint8 *buf, gsize len) if (ret < 0) return ret; + /* Fix-up on-demand body header type and final bit. This + * breaks the layers of abstraction a bit but it's the + * simplest way to avoid two consecutive empty packets */ + if (g_obex_header_get_id(hdr) == G_OBEX_HDR_ID_BODY && + ret == 3) { + buf[0] |= FINAL_BIT; + buf[count] = G_OBEX_HDR_ID_BODY_END; + } + count += ret; } -- 2.47.3