Rewrite http-upload slots to https

Actually that's not necessary as the XEP forbids to use http://
http-upload-enforce-https
Martin Dosch 7 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" "fmt"
"log" "log"
"net/http" "net/http"
"net/url"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strconv" "strconv"
"strings"
"github.com/beevik/etree" // BSD-2-clause "github.com/beevik/etree" // BSD-2-clause
"github.com/gabriel-vasile/mimetype" // MIT License "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 { if iqHTTPUploadSlotXMLPutURL == nil {
log.Fatal("http-upload: no url attribute") log.Fatal("http-upload: no url attribute")
} }
if !strings.HasPrefix(iqHTTPUploadSlotXMLPutURL.Value, "https://") { //if !strings.HasPrefix(iqHTTPUploadSlotXMLPutURL.Value, "https://") {
log.Fatal("http-upload: upload slot does not provide https") // log.Fatal("http-upload: upload slot does not provide https")
} //}
// Upload file // Upload file
putURL, err := url.Parse(iqHTTPUploadSlotXMLPutURL.Value)
if err != nil {
log.Fatal(err)
}
putURL.Scheme = "https"
httpClient := &http.Client{} httpClient := &http.Client{}
req, err := http.NewRequest(http.MethodPut, iqHTTPUploadSlotXMLPutURL.Value, req, err := http.NewRequest(http.MethodPut, putURL.String(),
buffer) buffer)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

Loading…
Cancel
Save