test1401 3.3 KB

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