Commit 1ac168e5 authored by Chris Conroy's avatar Chris Conroy Committed by Daniel Stenberg
Browse files

Fix RTSP GET_PARAMETER empty and non-empty operation.

Test coverage included. Thanks to Massimo Callegari for the bug report
parent 50b51161
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1345,7 +1345,9 @@ terminate the RTSP session since it is valid to control an RTSP session over
different connections.  (Added in 7.20.0)
.IP CURL_RTSPREQ_GET_PARAMETER
Retrieve a parameter from the server. By default, libcurl will automatically
include an \fIAccept: text/parameters\fP header unless a custom one is set.
include a \fIContent-Type: text/parameters\fP header on all non-empty requests
unless a custom one is set. GET_PARAMETER acts just like an HTTP PUT or POST
(see \fICURL_RTSPREQ_SET_PARAMETER\fP).
Applications wishing to send a heartbeat message (e.g. in the presence of a
server-specified timeout) should send use an empty GET_PARAMETER request.
(Added in 7.20.0)
+33 −30
Original line number Diff line number Diff line
@@ -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,6 +443,7 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
      data->set.httpreq = HTTPREQ_POST;
    }

    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:")) {
@@ -456,7 +454,8 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
          return result;
      }

    if(rtspreq == RTSPREQ_SET_PARAMETER) {
      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");
@@ -475,8 +474,12 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
      }

    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;
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
 test564 test1101 test1102 test1103 test1104 test299 test310 test311       \
 test312 test1105 test565 test800 test1106 test801 test566 test802 test803 \
 test1107 test1108 test1109 test1110 test1111 test1112 test129 test567     \
 test568 test569 test570 test571 test804
 test568 test569 test570 test571 test804 test572

filecheck:
	@mkdir test-place; \

tests/data/test572

0 → 100644
+121 −0
Original line number Diff line number Diff line
<testcase>

#Informational
<info>
<keywords>
RTSP
GET_PARAMETER
</keywords>
</info>

# Server-side
<reply>
<data1>
RTSP/1.0 200 OK
Server: RTSPD/libcurl-test
Session: getparams-test
CSeq: 1

</data1>

<data2>
RTSP/1.0 200 OK
Server: RTSPD/libcurl-test
Session: getparams-test
Content-Type: text/parameters
Content-Length: 32
Cseq: 2

scale=enormous
speed=ludicrous
</data2>

<data3>
RTSP/1.0 200 OK
Server: RTSPD/libcurl-test
Session: getparams-test
Cseq: 3

</data3>

<data4>
RTSP/1.0 200 Okie Dokie
Server: RTSPD/libcurl-test
Session: getparams-test
Cseq: 4
Content-Length: 37

packets_received: 1000
jitter: 0.314
</data4>
<data5>
RTSP/1.0 200 OK
Server: RTSPD/libcurl-test
Session: getparams-test
CSeq: 5
Curl-private: swsclose
Informational: Empty Options Response

</data5>
</reply>

# Client-Side
<client>
<server>
rtsp
</server>
<tool>
lib572
</tool>

<name>
RTSP GET_PARAMETER (Put/Heartbeat/Post)
</name>
<command>
rtsp://%HOSTIP:%RTSPPORT/572
</command>
# file written before test command runs
<file name="log/file572.txt">
scale
speed
</file>
</client>

<verify>
<strip>
^If-Modified-Since:.*
</strip>
<protocol>
SETUP rtsp://%HOSTIP:%RTSPPORT/5720001 RTSP/1.0
CSeq: 1
Transport: Planes/Trains/Automobiles

GET_PARAMETER rtsp://%HOSTIP:%RTSPPORT/5720002 RTSP/1.0
CSeq: 2
Session: getparams-test
Content-Length: 12
Content-Type: text/parameters

scale
speed
GET_PARAMETER rtsp://%HOSTIP:%RTSPPORT/5720003 RTSP/1.0
CSeq: 3
Session: getparams-test

GET_PARAMETER rtsp://%HOSTIP:%RTSPPORT/5720004 RTSP/1.0
CSeq: 4
Session: getparams-test
Content-Length: 24
Content-Type: text/parameters

packets_received
jitter
OPTIONS rtsp://%HOSTIP:%RTSPPORT/5720005 RTSP/1.0
CSeq: 5
Session: getparams-test

</protocol>
</verify>

</testcase>
+3 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
  lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \
  lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \
  lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \
  lib568 lib569 lib570 lib571
  lib568 lib569 lib570 lib571 lib572

lib500_SOURCES = lib500.c $(SUPPORTFILES)

@@ -143,3 +143,5 @@ lib570_SOURCES = lib570.c $(SUPPORTFILES)

lib571_SOURCES = lib571.c $(SUPPORTFILES)

lib572_SOURCES = lib572.c $(SUPPORTFILES)
Loading