Add error checks.

http_upload
Martin Dosch 5 years ago
parent 74967028d6
commit 6a781a7b97

@ -133,7 +133,10 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
} }
iqContent := <-c iqContent := <-c
close(c) close(c)
xml.Unmarshal(iqContent.Query, &iqDiscoItemsXML) err = xml.Unmarshal(iqContent.Query, &iqDiscoItemsXML)
if err != nil {
log.Fatal(err)
}
// Check the services reported by disco#items for the http upload service // Check the services reported by disco#items for the http upload service
for _, r := range iqDiscoItemsXML.Item { for _, r := range iqDiscoItemsXML.Item {
@ -147,7 +150,10 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
} }
iqDiscoInfo := <-c iqDiscoInfo := <-c
close(c) close(c)
xml.Unmarshal(iqDiscoInfo.Query, &iqDiscoInfoXML) err = xml.Unmarshal(iqDiscoInfo.Query, &iqDiscoInfoXML)
if err != nil {
log.Fatal(err)
}
if iqDiscoInfoXML.Identity.Type == "file" && iqDiscoInfoXML.Identity.Category == "store" { if iqDiscoInfoXML.Identity.Type == "file" && iqDiscoInfoXML.Identity.Category == "store" {
uploadComponent = r.Jid uploadComponent = r.Jid
@ -172,7 +178,10 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
} }
uploadSlot := <-c uploadSlot := <-c
close(c) close(c)
xml.Unmarshal(uploadSlot.Query, &iqHttpUploadSlotXML) err = xml.Unmarshal(uploadSlot.Query, &iqHttpUploadSlotXML)
if err != nil {
log.Fatal(err)
}
// Upload file // Upload file
httpClient := &http.Client{} httpClient := &http.Client{}

Loading…
Cancel
Save