test1401 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <testcase>
  2. <info>
  3. <keywords>
  4. HTTP
  5. HTTP GET
  6. HTTP Basic auth
  7. HTTP set cookie
  8. cookies
  9. --libcurl
  10. </keywords>
  11. </info>
  12. # Server-side
  13. <reply>
  14. <data>
  15. HTTP/1.1 200 OK
  16. Date: Thu, 29 Jul 2008 14:49:00 GMT
  17. Server: test-server/fake
  18. Content-Length: 0
  19. Content-Type: text/plain
  20. Connection: close
  21. </data>
  22. </reply>
  23. # Client-side
  24. <client>
  25. <server>
  26. http
  27. </server>
  28. <name>
  29. --libcurl for GET with various options
  30. </name>
  31. <setenv>
  32. SSL_CERT_FILE=
  33. </setenv>
  34. <command>
  35. http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl log/test%TESTNUMBER.c --basic -u fake:user -H "X-Files: Mulder" -H "X-Men: cyclops, iceman" -A MyUA -b chocolate=chip --proto "=http,ftp,file"
  36. </command>
  37. </client>
  38. # Verify data after the test has been "shot"
  39. <verify>
  40. <protocol>
  41. GET /we/want/%TESTNUMBER HTTP/1.1
  42. Host: %HOSTIP:%HTTPPORT
  43. Authorization: Basic ZmFrZTp1c2Vy
  44. User-Agent: MyUA
  45. Accept: */*
  46. Cookie: chocolate=chip
  47. X-Files: Mulder
  48. X-Men: cyclops, iceman
  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. struct curl_slist *slist1;
  69. slist1 = NULL;
  70. slist1 = curl_slist_append(slist1, "X-Files: Mulder");
  71. slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
  72. hnd = curl_easy_init();
  73. curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  74. curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
  75. curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
  76. curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
  77. curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
  78. curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
  79. curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
  80. curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip");
  81. curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
  82. %if ftp
  83. curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
  84. %endif
  85. curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
  86. curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "http,ftp,file");
  87. /* Here is a list of options the curl code used that cannot get generated
  88. as source easily. You may choose to either not use them or implement
  89. them yourself.
  90. CURLOPT_WRITEDATA set to a objectpointer
  91. CURLOPT_WRITEFUNCTION set to a functionpointer
  92. CURLOPT_READDATA set to a objectpointer
  93. CURLOPT_READFUNCTION set to a functionpointer
  94. CURLOPT_SEEKDATA set to a objectpointer
  95. CURLOPT_SEEKFUNCTION set to a functionpointer
  96. CURLOPT_ERRORBUFFER set to a objectpointer
  97. CURLOPT_STDERR set to a objectpointer
  98. CURLOPT_DEBUGFUNCTION set to a functionpointer
  99. CURLOPT_DEBUGDATA set to a objectpointer
  100. CURLOPT_HEADERFUNCTION set to a functionpointer
  101. CURLOPT_HEADERDATA set to a objectpointer
  102. */
  103. ret = curl_easy_perform(hnd);
  104. curl_easy_cleanup(hnd);
  105. hnd = NULL;
  106. curl_slist_free_all(slist1);
  107. slist1 = NULL;
  108. return (int)ret;
  109. }
  110. /**** End of sample code ****/
  111. </file>
  112. </verify>
  113. </testcase>