diff --git a/protocol/rtsp/rtsp.go b/protocol/rtsp/rtsp.go index e46fdeb5..7f032967 100644 --- a/protocol/rtsp/rtsp.go +++ b/protocol/rtsp/rtsp.go @@ -81,10 +81,10 @@ func (r *Request) Write(w io.Writer) error { // String returns a formatted string of the Request. func (r Request) String() string { var b strings.Builder - b.WriteString(r.Method + " " + r.URL.String() + " " + r.Proto + "/" + strconv.Itoa(r.ProtoMajor) + "." + strconv.Itoa(r.ProtoMinor) + "\r\n") + fmt.Fprintf(&b, "%s %s %s/%d.%d\r\n", r.Method, r.URL.String(), r.Proto, r.ProtoMajor, r.ProtoMinor) for k, v := range r.Header { for _, v := range v { - b.WriteString(k + ": " + v + "\r\n") + fmt.Fprintf(&b, "%s: %s\r\n", k, v) } } b.WriteString("\r\n") @@ -109,10 +109,10 @@ type Response struct { // String returns a formatted string of the Response. func (r Response) String() string { var b strings.Builder - b.WriteString(r.Proto + "/" + strconv.Itoa(r.ProtoMajor) + "." + strconv.Itoa(r.ProtoMinor) + " " + strconv.Itoa(r.StatusCode) + "\n") + fmt.Fprintf(&b, "%s/%d.%d %d\n", r.Proto, r.ProtoMajor, r.ProtoMinor, r.StatusCode) for k, v := range r.Header { for _, v := range v { - b.WriteString(k + ": " + v + "\n") + fmt.Fprintf(&b, "%s: %s", k, v) } } return b.String()