From 758cb6a3f2fa85142b244f74a81f747ff15c48d7 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Fri, 10 Apr 2020 12:16:57 +0200 Subject: [PATCH] Check IQ replies for type="result". --- httpupload.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/httpupload.go b/httpupload.go index 45e4908..28d9423 100644 --- a/httpupload.go +++ b/httpupload.go @@ -2,10 +2,6 @@ // Use of this source code is governed by the BSD-2-clause // license that can be found in the LICENSE file. -// TODO: -// * Check IQ replies for type='error' and type='wait' -// * What to do for 'wait'? We are impatient! - package main import ( @@ -132,6 +128,9 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string { } iqContent := <-c close(c) + if iqContent.Type != "result" { + log.Fatal("Error while disco#items query.") + } err = xml.Unmarshal(iqContent.Query, &iqDiscoItemsXML) if err != nil { log.Fatal(err) @@ -149,6 +148,9 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string { } iqDiscoInfo := <-c close(c) + if iqDiscoInfo.Type != "result" { + log.Fatal("Error while disco#info query.") + } err = xml.Unmarshal(iqDiscoInfo.Query, &iqDiscoInfoXML) if err != nil { log.Fatal(err) @@ -196,6 +198,9 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string { } uploadSlot := <-c close(c) + if uploadSlot.Type != "result" { + log.Fatal("Error while requesting upload slot.") + } err = xml.Unmarshal(uploadSlot.Query, &iqHttpUploadSlotXML) if err != nil { log.Fatal(err)