From 3a51dce786d76b204aab32d7207ed459efdfcca7 Mon Sep 17 00:00:00 2001 From: hypafrag Date: Sat, 13 Oct 2018 19:45:48 +0700 Subject: [PATCH] added charsets support --- config.go | 6 +++++- session.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 21dc262..c6f8d5e 100644 --- a/config.go +++ b/config.go @@ -1,6 +1,9 @@ package xmpp // import "fluux.io/xmpp" -import "os" +import ( + "io" + "os" +) type Config struct { Address string @@ -12,4 +15,5 @@ type Config struct { Retry int // Number of retries for connect ConnectTimeout int // Connection timeout in seconds. Default to 15 Insecure bool // set to true to allow comms without TLS + CharsetReader func(charset string, input io.Reader) (io.Reader, error) // passed to xml decoder } diff --git a/session.go b/session.go index bdeb75c..60080ce 100644 --- a/session.go +++ b/session.go @@ -82,6 +82,7 @@ func (s *Session) setProxy(conn net.Conn, newConn net.Conn, o Config) { s.socketProxy = newSocketProxy(newConn, o.PacketLogger) } s.decoder = xml.NewDecoder(s.socketProxy) + s.decoder.CharsetReader = o.CharsetReader } func (s *Session) open(domain string) (f streamFeatures) {