Merge branch 'master' of github.com:foomo/soap

This commit is contained in:
Florian Schlegel 2016-03-03 13:25:35 +01:00
commit 1cc2286d4c
2 changed files with 5 additions and 5 deletions

View File

@ -84,13 +84,14 @@ func (s *Server) handleError(err error, w http.ResponseWriter) {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte("could not marshal soap fault for: " + err.Error() + " xmlError: " + xmlErr.Error()))
} else {
sendSOAPHeader(w)
sendSOAPHeader(w, len(xmlBytes))
w.Write(xmlBytes)
}
}
func sendSOAPHeader(w http.ResponseWriter) {
func sendSOAPHeader(w http.ResponseWriter, contentLength int) {
w.Header().Add("Content-Type", SOAPContentType)
w.Header().Add("Content-Length", fmt.Sprint(contentLength))
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@ -169,8 +170,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err != nil {
s.handleError(errors.New("could not marshal response:: "+err.Error()), w)
}
sendSOAPHeader(w)
w.Header().Set("Content-Length", fmt.Sprint(len(xmlBytes)))
sendSOAPHeader(w, len(xmlBytes))
w.Write(xmlBytes)
} else {
l("action handler sent its own output")

View File

@ -5,7 +5,7 @@ import (
"log"
)
//var SOAPContentType = "application/soap+xml; charset=\"utf-8\""
// SOAPContentType configurable soap content type
var SOAPContentType = "text/xml; charset=\"utf-8\""
// Verbose be verbose