diff --git a/files_download_file.go b/files_download_file.go index 99913a29..f1cc58c7 100644 --- a/files_download_file.go +++ b/files_download_file.go @@ -94,7 +94,9 @@ func (b *downloadFileBuilder) Execute() (*PNDownloadFileResponse, StatusResponse var respDL *PNDownloadFileResponse if b.opts.CipherKey == "" && b.opts.pubnub.cryptoModule == nil { - + respDL = &PNDownloadFileResponse{ + File: resp.Body, + } } else { var e error cryptoModule := b.opts.pubnub.getCryptoModule() diff --git a/publish_request_test.go b/publish_request_test.go index 23989e6e..0bf42dfe 100644 --- a/publish_request_test.go +++ b/publish_request_test.go @@ -191,10 +191,10 @@ func AssertSuccessPublishGetMeta(t *testing.T, expectedString string, message in assert.Nil(err1) } -func AssertSuccessPublishPost(t *testing.T, expectedBody string, message interface{}) { +func AssertSuccessPublishPost(t *testing.T, pn *PubNub, expectedBody string, message interface{}) { assert := assert.New(t) - opts := newPublishOpts(pubnub, pubnub.ctx) + opts := newPublishOpts(pn, pn.ctx) opts.Channel = "ch" opts.Message = message opts.UsePost = true @@ -215,6 +215,7 @@ func AssertSuccessPublishPost(t *testing.T, expectedBody string, message interfa } func TestPublishMixedGet(t *testing.T) { + pn := NewPubNub(NewDemoConfig()) type msg struct { One string `json:"one"` Two string `json:"two"` @@ -270,6 +271,8 @@ func TestPublishMixedGet(t *testing.T) { } func TestPublishMixedPost(t *testing.T) { + pn := NewPubNub(NewDemoConfig()) + type msg struct { One string `json:"one"` Two string `json:"two"` @@ -282,16 +285,16 @@ func TestPublishMixedPost(t *testing.T) { msgMap["two"] = "hey2" msgMap["three"] = "hey3" - AssertSuccessPublishPost(t, "12", 12) - AssertSuccessPublishPost(t, "\"hey\"", "hey") - AssertSuccessPublishPost(t, "true", true) - AssertSuccessPublishPost(t, "[\"hey1\",\"hey2\",\"hey3\"]", + AssertSuccessPublishPost(t, pn, "12", 12) + AssertSuccessPublishPost(t, pn, "\"hey\"", "hey") + AssertSuccessPublishPost(t, pn, "true", true) + AssertSuccessPublishPost(t, pn, "[\"hey1\",\"hey2\",\"hey3\"]", []string{"hey1", "hey2", "hey3"}) - AssertSuccessPublishPost(t, "[1,2,3]", []int{1, 2, 3}) - AssertSuccessPublishPost(t, + AssertSuccessPublishPost(t, pn, "[1,2,3]", []int{1, 2, 3}) + AssertSuccessPublishPost(t, pn, "{\"one\":\"hey1\",\"two\":\"hey2\",\"three\":\"hey3\"}", msgStruct) - AssertSuccessPublishPost(t, + AssertSuccessPublishPost(t, pn, "{\"one\":\"hey1\",\"three\":\"hey3\",\"two\":\"hey2\"}", msgMap) } diff --git a/subscription_manager.go b/subscription_manager.go index 8d019587..1873f313 100644 --- a/subscription_manager.go +++ b/subscription_manager.go @@ -661,7 +661,7 @@ func processNonPresencePayload(m *SubscriptionManager, payload subscribeMessage, m.listenerManager.announceMessageActionsEvent(pnMessageActionsEvent) case PNMessageTypeFile: var err error - messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.cryptoModule) + messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.getCryptoModule()) if err != nil { pnStatus := &PNStatus{ Category: PNBadRequestCategory, @@ -680,7 +680,7 @@ func processNonPresencePayload(m *SubscriptionManager, payload subscribeMessage, m.listenerManager.announceFile(pnFilesEvent) default: var err error - messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.cryptoModule) + messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.getCryptoModule()) if err != nil { pnStatus := &PNStatus{ Category: PNBadRequestCategory,