test1401 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/1401 --libcurl log/test1401.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. <strip>
  41. ^User-Agent:.*
  42. </strip>
  43. <protocol>
  44. GET /we/want/1401 HTTP/1.1
  45. Host: %HOSTIP:%HTTPPORT
  46. User-Agent: stripped
  47. Authorization: Basic ZmFrZTp1c2Vy
  48. Accept: */*
  49. Cookie: chocolate=chip
  50. X-Files: Mulder
  51. X-Men: cyclops, iceman
  52. </protocol>
  53. <stripfile>
  54. # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
  55. # configurations - just ignore them
  56. $_ = '' if /CURLOPT_SSL_VERIFYPEER/
  57. $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
  58. $_ = '' if /CURLOPT_HTTP_VERSION/
  59. </stripfile>
  60. <file name="log/test1401.c" mode="text">
  61. /********* Sample code generated by the curl command line tool **********
  62. * All curl_easy_setopt() options are documented at:
  63. * https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
  64. ************************************************************************/
  65. #include <curl/curl.h>
  66. int main(int argc, char *argv[])
  67. {
  68. CURLcode ret;
  69. CURL *hnd;
  70. struct curl_slist *slist1;
  71. slist1 = NULL;
  72. slist1 = curl_slist_append(slist1, "X-Files: Mulder");
  73. slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
  74. hnd = curl_easy_init();
  75. curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  76. curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1401");
  77. curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
  78. curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
  79. curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
  80. curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
  81. curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
  82. curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip");
  83. curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
  84. curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
  85. curl_easy_setopt(hnd, CURLOPT_PROTOCOLS, (long)CURLPROTO_FILE |
  86. (long)CURLPROTO_FTP |
  87. (long)CURLPROTO_HTTP);
  88. /* Here is a list of options the curl code used that cannot get generated
  89. as source easily. You may select to either not use them or implement
  90. them yourself.
  91. CURLOPT_WRITEDATA set to a objectpointer
  92. CURLOPT_INTERLEAVEDATA set to a objectpointer
  93. CURLOPT_WRITEFUNCTION set to a functionpointer
  94. CURLOPT_READDATA set to a objectpointer
  95. CURLOPT_READFUNCTION set to a functionpointer
  96. CURLOPT_SEEKDATA set to a objectpointer
  97. CURLOPT_SEEKFUNCTION set to a functionpointer
  98. CURLOPT_ERRORBUFFER set to a objectpointer
  99. CURLOPT_STDERR set to a objectpointer
  100. CURLOPT_DEBUGFUNCTION set to a functionpointer
  101. CURLOPT_DEBUGDATA set to a objectpointer
  102. CURLOPT_HEADERFUNCTION set to a functionpointer
  103. CURLOPT_HEADERDATA set to a objectpointer
  104. */
  105. ret = curl_easy_perform(hnd);
  106. curl_easy_cleanup(hnd);
  107. hnd = NULL;
  108. curl_slist_free_all(slist1);
  109. slist1 = NULL;
  110. return (int)ret;
  111. }
  112. /**** End of sample code ****/
  113. </file>
  114. </verify>
  115. </testcase>