Rewrite http-upload slots to https

Actually that's not necessary as the XEP forbids to use http://
http-upload-enforce-https
Martin Dosch 6 months ago
parent a320fb624e
commit b433cf69cc
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

@ -10,11 +10,11 @@ import (
"fmt"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"github.com/beevik/etree" // BSD-2-clause
"github.com/gabriel-vasile/mimetype" // MIT License
@ -186,12 +186,17 @@ func httpUpload(client *xmpp.Client, iqc chan xmpp.IQ, jserver string, filePath
if iqHTTPUploadSlotXMLPutURL == nil {
log.Fatal("http-upload: no url attribute")
}
if !strings.HasPrefix(iqHTTPUploadSlotXMLPutURL.Value, "https://") {
log.Fatal("http-upload: upload slot does not provide https")
}
//if !strings.HasPrefix(iqHTTPUploadSlotXMLPutURL.Value, "https://") {
// log.Fatal("http-upload: upload slot does not provide https")
//}
// Upload file
putURL, err := url.Parse(iqHTTPUploadSlotXMLPutURL.Value)
if err != nil {
log.Fatal(err)
}
putURL.Scheme = "https"
httpClient := &http.Client{}
req, err := http.NewRequest(http.MethodPut, iqHTTPUploadSlotXMLPutURL.Value,
req, err := http.NewRequest(http.MethodPut, putURL.String(),
buffer)
if err != nil {
log.Fatal(err)

Loading…
Cancel
Save