From 5b148c6fc578a30bd1b57f14fa63e1f337d86c05 Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Tue, 24 Jul 2018 12:26:21 +0200 Subject: [PATCH 1/2] Set the Accept http header to the mime type of the selected encoder --- Source/ARTRest.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/ARTRest.m b/Source/ARTRest.m index d1860fc14..49c2f8042 100644 --- a/Source/ARTRest.m +++ b/Source/ARTRest.m @@ -238,8 +238,7 @@ - (void)executeRequest:(NSURLRequest *)request completion:(void (^)(NSHTTPURLRes if ([request isKindOfClass:[NSMutableURLRequest class]]) { NSMutableURLRequest *mutableRequest = (NSMutableURLRequest *)request; - NSString *accept = [[_encoders.allValues valueForKeyPath:@"mimeType"] componentsJoinedByString:@","]; - [mutableRequest setValue:accept forHTTPHeaderField:@"Accept"]; + [mutableRequest setValue:[[self defaultEncoder] mimeType] forHTTPHeaderField:@"Accept"]; [mutableRequest setValue:[ARTDefault version] forHTTPHeaderField:@"X-Ably-Version"]; [mutableRequest setValue:[ARTDefault libraryVersion] forHTTPHeaderField:@"X-Ably-Lib"]; [mutableRequest setTimeoutInterval:_options.httpRequestTimeout]; From a6739bc2ef9013532a48c13fc6d4abc2980d05aa Mon Sep 17 00:00:00 2001 From: Cesare Rocchi Date: Tue, 24 Jul 2018 15:38:27 +0200 Subject: [PATCH 2/2] Add test for TM2a --- Spec/RealtimeClientChannel.swift | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Spec/RealtimeClientChannel.swift b/Spec/RealtimeClientChannel.swift index b90069211..debb9006d 100644 --- a/Spec/RealtimeClientChannel.swift +++ b/Spec/RealtimeClientChannel.swift @@ -3464,7 +3464,27 @@ class RealtimeClientChannel: QuickSpec { } } } - + } + + describe("message attributes") { + + // TM2a + it("if the message does not contain an id, it should be set to protocolMsgId:index") { + let client = ARTRealtime(options: AblyTests.commonAppSetup()) + defer { client.dispose(); client.close() } + let p = ARTProtocolMessage() + p.id = "protocolId" + let m = ARTMessage(name: nil, data: "message without ID") + p.messages = [m] + let channel = client.channels.get(NSUUID().uuidString) + waitUntil(timeout: testTimeout) { done in + channel.subscribe{ message in + expect(message.id).to(equal("protocolId:0")) + done() + } + channel.onMessage(p) + } + } } } }