apple / swift-nio-imap

A Swift project that provides an implementation of the IMAP4rev1 protocol, built upon SwiftNIO.
Apache License 2.0
97 stars 13 forks source link

Allow NIL response for a particular body section #720

Closed danieleggert closed 1 year ago

danieleggert commented 1 year ago

Allow NIL response for a particular body section

Motivation:

The RFC 3501 section 7.4.2 FETCH response for a BODY[<section>]<<origin octet>> (or the corresponding BINARY from RFC 3516) is allowed to be NIL (it’s an nstring), corresponding to a non-existing body section.

For example, if the client requests BODY.PEEK[4.2] and there’s no 4.2 for that particular message, the server will respond with BODY[4.2] NIL.

Modifications:

Add a MessageAttribute corresponding to this NIL value.

Note that the non-nil version uses FetchResponse.streamingBegin(…), .streamingBytes(…), and .streamingEnd, whereas the NIL variant uses FetchResponse.simpleAttribute since it won’t be streaming any data.

Added test cases for encoding and parsing.