test1465 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 POST with binary content
  27. </name>
  28. <setenv>
  29. SSL_CERT_FILE=
  30. </setenv>
  31. <command>
  32. http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl log/test%TESTNUMBER.c --data-binary @log/%TESTNUMBER-upload
  33. </command>
  34. # abcd�e�fghi
  35. <file name="log/%TESTNUMBER-upload">
  36. %hex[abcd%00e%00fghi]hex%
  37. </file>
  38. </client>
  39. # Verify data after the test has been "shot"
  40. <verify>
  41. <protocol>
  42. POST /we/want/%TESTNUMBER HTTP/1.1
  43. Host: %HOSTIP:%HTTPPORT
  44. User-Agent: curl/%VERSION
  45. Accept: */*
  46. Content-Length: 12
  47. Content-Type: application/x-www-form-urlencoded
  48. %hex[abcd%00e%00fghi]hex%
  49. </protocol>
  50. <stripfile>
  51. # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
  52. # configurations - just ignore them
  53. $_ = '' if /CURLOPT_SSL_VERIFYPEER/
  54. $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
  55. $_ = '' if /CURLOPT_HTTP_VERSION/
  56. $_ = '' if /CURLOPT_INTERLEAVEDATA/
  57. </stripfile>
  58. <file name="log/test%TESTNUMBER.c" mode="text">
  59. /********* Sample code generated by the curl command line tool **********
  60. * All curl_easy_setopt() options are documented at:
  61. * https://curl.se/libcurl/c/curl_easy_setopt.html
  62. ************************************************************************/
  63. #include <curl/curl.h>
  64. int main(int argc, char *argv[])
  65. {
  66. CURLcode ret;
  67. CURL *hnd;
  68. hnd = curl_easy_init();
  69. curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  70. curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
  71. curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "abcd\x00e\x00fghi\n");
  72. curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)12);
  73. curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION");
  74. curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
  75. curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
  76. %if ftp
  77. curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
  78. %endif
  79. curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
  80. /* Here is a list of options the curl code used that cannot get generated
  81. as source easily. You may choose to either not use them or implement
  82. them yourself.
  83. CURLOPT_WRITEDATA set to a objectpointer
  84. CURLOPT_WRITEFUNCTION set to a functionpointer
  85. CURLOPT_READDATA set to a objectpointer
  86. CURLOPT_READFUNCTION set to a functionpointer
  87. CURLOPT_SEEKDATA set to a objectpointer
  88. CURLOPT_SEEKFUNCTION set to a functionpointer
  89. CURLOPT_ERRORBUFFER set to a objectpointer
  90. CURLOPT_STDERR set to a objectpointer
  91. CURLOPT_DEBUGFUNCTION set to a functionpointer
  92. CURLOPT_DEBUGDATA set to a objectpointer
  93. CURLOPT_HEADERFUNCTION set to a functionpointer
  94. CURLOPT_HEADERDATA set to a objectpointer
  95. */
  96. ret = curl_easy_perform(hnd);
  97. curl_easy_cleanup(hnd);
  98. hnd = NULL;
  99. return (int)ret;
  100. }
  101. /**** End of sample code ****/
  102. </file>
  103. </verify>
  104. </testcase>