diff options
author | Chris Conroy <cconroy@gmail.com> | 2010-03-24 01:35:03 -0400 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2010-03-24 13:21:14 +0100 |
commit | 1ac168e576d8e78b58640e1e997249717529b482 (patch) | |
tree | 28e15363ef86b15292b5025ec05b8f66cb53cb9f /lib | |
parent | 50b51161c9ae3833489d2bf42b43fced46ab5587 (diff) |
Fix RTSP GET_PARAMETER empty and non-empty operation.
Test coverage included. Thanks to Massimo Callegari for the bug report
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rtsp.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/lib/rtsp.c b/lib/rtsp.c index cf8b79777..8cc200bda 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -234,8 +234,8 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done) p_request = "TEARDOWN"; break; case RTSPREQ_GET_PARAMETER: + /* GET_PARAMETER's no_body status is determined later */ p_request = "GET_PARAMETER"; - data->set.opt_no_body = FALSE; break; case RTSPREQ_SET_PARAMETER: p_request = "SET_PARAMETER"; @@ -321,12 +321,6 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done) } } - /* Default to text/parameters for GET_PARAMETER */ - if(rtspreq == RTSPREQ_GET_PARAMETER) { - p_accept = Curl_checkheaders(data, "Accept:")? - NULL:"Accept: text/parameters\r\n"; - } - /* The User-Agent string might have been allocated in url.c already, because it might have been used in the proxy connect, but if we have got a header with the user-agent string specified, we erase the previously made string @@ -433,7 +427,10 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done) if(result) return result; - if(rtspreq == RTSPREQ_ANNOUNCE || rtspreq == RTSPREQ_SET_PARAMETER) { + if(rtspreq == RTSPREQ_ANNOUNCE || + rtspreq == RTSPREQ_SET_PARAMETER || + rtspreq == RTSPREQ_GET_PARAMETER) { + if(data->set.upload) { putsize = data->set.infilesize; data->set.httpreq = HTTPREQ_PUT; @@ -446,38 +443,44 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done) data->set.httpreq = HTTPREQ_POST; } - /* As stated in the http comments, it is probably not wise to - * actually set a custom Content-Length in the headers */ - if(!Curl_checkheaders(data, "Content-Length:")) { - result = Curl_add_bufferf(req_buffer, - "Content-Length: %" FORMAT_OFF_T"\r\n", - (data->set.upload ? putsize : postsize)); - if(result) - return result; - } - - if(rtspreq == RTSPREQ_SET_PARAMETER) { - if(!Curl_checkheaders(data, "Content-Type:")) { + if(putsize > 0 || postsize > 0) { + /* As stated in the http comments, it is probably not wise to + * actually set a custom Content-Length in the headers */ + if(!Curl_checkheaders(data, "Content-Length:")) { result = Curl_add_bufferf(req_buffer, - "Content-Type: text/parameters\r\n"); + "Content-Length: %" FORMAT_OFF_T"\r\n", + (data->set.upload ? putsize : postsize)); if(result) return result; } - } - if(rtspreq == RTSPREQ_ANNOUNCE) { - if(!Curl_checkheaders(data, "Content-Type:")) { - result = Curl_add_bufferf(req_buffer, - "Content-Type: application/sdp\r\n"); - if(result) - return result; + if(rtspreq == RTSPREQ_SET_PARAMETER || + rtspreq == RTSPREQ_GET_PARAMETER) { + if(!Curl_checkheaders(data, "Content-Type:")) { + result = Curl_add_bufferf(req_buffer, + "Content-Type: text/parameters\r\n"); + if(result) + return result; + } + } + + if(rtspreq == RTSPREQ_ANNOUNCE) { + if(!Curl_checkheaders(data, "Content-Type:")) { + result = Curl_add_bufferf(req_buffer, + "Content-Type: application/sdp\r\n"); + if(result) + return result; + } } - } data->state.expect100header = FALSE; /* RTSP posts are simple/small */ + } else if(rtspreq == RTSPREQ_GET_PARAMETER) { + /* Check for an empty GET_PARAMETER (heartbeat) request */ + data->set.httpreq = HTTPREQ_HEAD; + data->set.opt_no_body = TRUE; + } } - /* RTSP never allows chunked transfer */ data->req.forbidchunk = TRUE; /* Finish the request buffer */ |