Remove element name match test from Stream.Next().
Only one place still used it, so it might as well go.
This commit is contained in:
parent
6dfd9e096b
commit
f97ed9ea37
|
|
@ -150,7 +150,7 @@ func authenticatePlain(stream *Stream, user, password string) error {
|
|||
}
|
||||
|
||||
func authenticateResponse(stream *Stream) error {
|
||||
if se, err := stream.Next(nil); err != nil {
|
||||
if se, err := stream.Next(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
switch se.Name.Local {
|
||||
|
|
|
|||
|
|
@ -70,8 +70,12 @@ func handshake(stream *Stream, streamId, secret string) error {
|
|||
}
|
||||
|
||||
// Get handshake response.
|
||||
if _, err := stream.Next(&xml.Name{"jabber:component:accept", "handshake"}); err != nil {
|
||||
if start, err := stream.Next(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if start.Name != (xml.Name{"jabber:component:accept", "handshake"}) {
|
||||
return fmt.Errorf("Expected <handshake/>, for %s", start.Name)
|
||||
}
|
||||
}
|
||||
if err := stream.Skip(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
|
|
@ -124,11 +123,10 @@ func (stream *Stream) send(b []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Find start of next stanza. If match is not nil the stanza's XML name
|
||||
// is compared and must be equal.
|
||||
// Find start of next stanza.
|
||||
// Bad things are very likely to happen if a call to Next() is successful but
|
||||
// you don't actually decode or skip the element.
|
||||
func (stream *Stream) Next(match *xml.Name) (*xml.StartElement, error) {
|
||||
func (stream *Stream) Next() (*xml.StartElement, error) {
|
||||
|
||||
start, err := nextStartElement(stream.dec)
|
||||
if err != nil {
|
||||
|
|
@ -144,10 +142,6 @@ func (stream *Stream) Next(match *xml.Name) (*xml.StartElement, error) {
|
|||
log.Println("recv:", stream.stanzaBuf)
|
||||
}
|
||||
|
||||
if match != nil && start.Name != *match {
|
||||
return nil, fmt.Errorf("Expected %s, got %s", *match, start.Name)
|
||||
}
|
||||
|
||||
return start, nil
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +188,7 @@ func (stream *Stream) DecodeElement(v interface{}, start *xml.StartElement) erro
|
|||
// Explicity lookup next start element to ensure stream is validated,
|
||||
// stanza is logged, etc.
|
||||
if start == nil {
|
||||
if se, err := stream.Next(nil); err != nil {
|
||||
if se, err := stream.Next(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
start = se
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ func (x *XMPP) receiver() {
|
|||
defer close(x.in)
|
||||
|
||||
for {
|
||||
start, err := x.stream.Next(nil)
|
||||
start, err := x.stream.Next()
|
||||
if err != nil {
|
||||
x.in <- err
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue