Have util.{Serialize,Deserialize}SessionDescription return an error

https://bugs.torproject.org/33897#comment:4
This commit is contained in:
David Fifield 2020-04-27 18:45:10 -06:00
parent 76732155e7
commit b48fb781ee
3 changed files with 26 additions and 27 deletions

View file

@ -96,7 +96,11 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
SDP: util.StripLocalAddresses(offer.SDP),
}
}
data := bytes.NewReader([]byte(util.SerializeSessionDescription(offer)))
offerSDP, err := util.SerializeSessionDescription(offer)
if err != nil {
return nil, err
}
data := bytes.NewReader([]byte(offerSDP))
// Suffix with broker's client registration handler.
clientURL := bc.url.ResolveReference(&url.URL{Path: "client"})
request, err := http.NewRequest("POST", clientURL.String(), data)
@ -119,8 +123,7 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
if nil != err {
return nil, err
}
answer := util.DeserializeSessionDescription(string(body))
return answer, nil
return util.DeserializeSessionDescription(string(body))
case http.StatusServiceUnavailable:
return nil, errors.New(BrokerError503)
case http.StatusBadRequest: