rename Response and Request's Content into Body

This commit is contained in:
aler9
2021-01-06 18:48:29 +01:00
parent 3aac61b762
commit d0834e7446
11 changed files with 23 additions and 23 deletions

View File

@@ -413,7 +413,7 @@ func (c *ClientConn) Describe(u *base.URL) (Tracks, *base.Response, error) {
return nil, nil, fmt.Errorf("wrong Content-Type, expected application/sdp")
}
tracks, err := ReadTracks(res.Content)
tracks, err := ReadTracks(res.Body)
if err != nil {
return nil, nil, err
}

View File

@@ -36,7 +36,7 @@ func (c *ClientConn) Announce(u *base.URL, tracks Tracks) (*base.Response, error
Header: base.Header{
"Content-Type": base.HeaderValue{"application/sdp"},
},
Content: tracks.Write(),
Body: tracks.Write(),
})
if err != nil {
return nil, err

View File

@@ -47,7 +47,7 @@ func handleConn(conn *gortsplib.ServerConn) {
"Content-Base": base.HeaderValue{req.URL.String() + "/"},
"Content-Type": base.HeaderValue{"application/sdp"},
},
Content: sdp,
Body: sdp,
}, nil
}

View File

@@ -46,7 +46,7 @@ func handleConn(conn *gortsplib.ServerConn) {
"Content-Base": base.HeaderValue{req.URL.String() + "/"},
"Content-Type": base.HeaderValue{"application/sdp"},
},
Content: sdp,
Body: sdp,
}, nil
}

View File

@@ -46,7 +46,7 @@ func handleConn(conn *gortsplib.ServerConn) {
"Content-Base": base.HeaderValue{req.URL.String() + "/"},
"Content-Type": base.HeaderValue{"application/sdp"},
},
Content: sdp,
Body: sdp,
}, nil
}

View File

@@ -43,8 +43,8 @@ type Request struct {
// map of header values
Header Header
// optional payload
Content []byte
// optional body
Body []byte
// whether to wait for a response or not
// used only by ClientConn.Do()
@@ -99,7 +99,7 @@ func (req *Request) Read(rb *bufio.Reader) error {
return err
}
err = (*payload)(&req.Content).read(rb, req.Header)
err = (*payload)(&req.Body).read(rb, req.Header)
if err != nil {
return err
}
@@ -115,8 +115,8 @@ func (req Request) Write(bw *bufio.Writer) error {
return err
}
if len(req.Content) != 0 {
req.Header["Content-Length"] = HeaderValue{strconv.FormatInt(int64(len(req.Content)), 10)}
if len(req.Body) != 0 {
req.Header["Content-Length"] = HeaderValue{strconv.FormatInt(int64(len(req.Body)), 10)}
}
err = req.Header.write(bw)
@@ -124,7 +124,7 @@ func (req Request) Write(bw *bufio.Writer) error {
return err
}
err = payload(req.Content).write(bw)
err = payload(req.Body).write(bw)
if err != nil {
return err
}

View File

@@ -90,7 +90,7 @@ var casesRequest = []struct {
"Content-Type": HeaderValue{"application/sdp"},
"Content-Length": HeaderValue{"306"},
},
Content: []byte("v=0\n" +
Body: []byte("v=0\n" +
"o=mhandley 2890844526 2890845468 IN IP4 126.16.64.4\n" +
"s=SDP Seminar\n" +
"i=A Seminar on the session description protocol\n" +
@@ -123,7 +123,7 @@ var casesRequest = []struct {
"Session": HeaderValue{"12345678"},
"Content-Length": HeaderValue{"24"},
},
Content: []byte("packets_received\n" +
Body: []byte("packets_received\n" +
"jitter\n",
),
},

View File

@@ -129,8 +129,8 @@ type Response struct {
// map of header values
Header Header
// optional payload
Content []byte
// optional body
Body []byte
}
// Read reads a response.
@@ -177,7 +177,7 @@ func (res *Response) Read(rb *bufio.Reader) error {
return err
}
err = (*payload)(&res.Content).read(rb, res.Header)
err = (*payload)(&res.Body).read(rb, res.Header)
if err != nil {
return err
}
@@ -198,8 +198,8 @@ func (res Response) Write(bw *bufio.Writer) error {
return err
}
if len(res.Content) != 0 {
res.Header["Content-Length"] = HeaderValue{strconv.FormatInt(int64(len(res.Content)), 10)}
if len(res.Body) != 0 {
res.Header["Content-Length"] = HeaderValue{strconv.FormatInt(int64(len(res.Body)), 10)}
}
err = res.Header.write(bw)
@@ -207,7 +207,7 @@ func (res Response) Write(bw *bufio.Writer) error {
return err
}
err = payload(res.Content).write(bw)
err = payload(res.Body).write(bw)
if err != nil {
return err
}

View File

@@ -87,7 +87,7 @@ var casesResponse = []struct {
"Content-Type": HeaderValue{"application/sdp"},
"CSeq": HeaderValue{"2"},
},
Content: []byte("m=video 0 RTP/AVP 96\n" +
Body: []byte("m=video 0 RTP/AVP 96\n" +
"a=control:streamid=0\n" +
"a=range:npt=0-7.741000\n" +
"a=length:npt=7.741000\n" +

View File

@@ -117,7 +117,7 @@ func (ts *testServ) handleConn(conn *ServerConn) {
"Content-Base": base.HeaderValue{req.URL.String() + "/"},
"Content-Type": base.HeaderValue{"application/sdp"},
},
Content: ts.sdp,
Body: ts.sdp,
}, nil
}

View File

@@ -325,7 +325,7 @@ func (sc *ServerConn) handleRequest(req *base.Request) (*base.Response, error) {
}, fmt.Errorf("unsupported Content-Type '%s'", ct)
}
tracks, err := ReadTracks(req.Content)
tracks, err := ReadTracks(req.Body)
if err != nil {
return &base.Response{
StatusCode: base.StatusBadRequest,
@@ -580,7 +580,7 @@ func (sc *ServerConn) handleRequest(req *base.Request) (*base.Response, error) {
Header: base.Header{
"Content-Type": base.HeaderValue{"text/parameters"},
},
Content: []byte("\n"),
Body: []byte("\n"),
}, nil
case base.SetParameter: