test1402 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <testcase>
  2. <info>
  3. <keywords>
  4. HTTP
  5. HTTP POST
  6. --libcurl
  7. </keywords>
  8. </info>
  9. # Server-side
  10. <reply>
  11. <data>
  12. HTTP/1.1 200 OK
  13. Date: Thu, 29 Jul 2008 14:49:00 GMT
  14. Server: test-server/fake
  15. Content-Length: 0
  16. Content-Type: text/plain
  17. Connection: close
  18. </data>
  19. </reply>
  20. # Client-side
  21. <client>
  22. <server>
  23. http
  24. </server>
  25. <name>
  26. --libcurl for simple POST
  27. </name>
  28. <setenv>
  29. SSL_CERT_FILE=
  30. </setenv>
  31. <command>
  32. http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c -d "foo=bar" -d "baz=quux"
  33. </command>
  34. </client>
  35. # Verify data after the test has been "shot"
  36. <verify>
  37. <protocol nonewline="yes">
  38. POST /we/want/%TESTNUMBER HTTP/1.1
  39. Host: %HOSTIP:%HTTPPORT
  40. User-Agent: curl/%VERSION
  41. Accept: */*
  42. Content-Length: 16
  43. Content-Type: application/x-www-form-urlencoded
  44. foo=bar&baz=quux
  45. </protocol>
  46. <stripfile>
  47. # curl's default user-agent varies with version, libraries etc.
  48. s/(USERAGENT, \")[^\"]+/${1}stripped/
  49. # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
  50. # configurations - just ignore them
  51. $_ = '' if /CURLOPT_SSL_VERIFYPEER/
  52. $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
  53. $_ = '' if /CURLOPT_HTTP_VERSION/
  54. $_ = '' if /CURLOPT_INTERLEAVEDATA/
  55. </stripfile>
  56. <file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
  57. /********* Sample code generated by the curl command line tool **********
  58. * All curl_easy_setopt() options are documented at:
  59. * https://curl.se/libcurl/c/curl_easy_setopt.html
  60. ************************************************************************/
  61. #include <curl/curl.h>
  62. int main(int argc, char *argv[])
  63. {
  64. CURLcode ret;
  65. CURL *hnd;
  66. hnd = curl_easy_init();
  67. curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  68. curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
  69. curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux");
  70. curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16);
  71. curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
  72. curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
  73. curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
  74. %if ftp
  75. curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
  76. %endif
  77. curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
  78. /* Here is a list of options the curl code used that cannot get generated
  79. as source easily. You may choose to either not use them or implement
  80. them yourself.
  81. CURLOPT_WRITEDATA was set to an object pointer
  82. CURLOPT_WRITEFUNCTION was set to a function pointer
  83. CURLOPT_READDATA was set to an object pointer
  84. CURLOPT_READFUNCTION was set to a function pointer
  85. CURLOPT_SEEKDATA was set to an object pointer
  86. CURLOPT_SEEKFUNCTION was set to a function pointer
  87. CURLOPT_ERRORBUFFER was set to an object pointer
  88. CURLOPT_STDERR was set to an object pointer
  89. CURLOPT_DEBUGFUNCTION was set to a function pointer
  90. CURLOPT_DEBUGDATA was set to an object pointer
  91. CURLOPT_HEADERFUNCTION was set to a function pointer
  92. CURLOPT_HEADERDATA was set to an object pointer
  93. */
  94. ret = curl_easy_perform(hnd);
  95. curl_easy_cleanup(hnd);
  96. hnd = NULL;
  97. return (int)ret;
  98. }
  99. /**** End of sample code ****/
  100. </file>
  101. </verify>
  102. </testcase>