c-hyper.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #if !defined(CURL_DISABLE_HTTP) && defined(USE_HYPER)
  26. #ifdef HAVE_NETINET_IN_H
  27. #include <netinet/in.h>
  28. #endif
  29. #ifdef HAVE_NETDB_H
  30. #include <netdb.h>
  31. #endif
  32. #ifdef HAVE_ARPA_INET_H
  33. #include <arpa/inet.h>
  34. #endif
  35. #ifdef HAVE_NET_IF_H
  36. #include <net/if.h>
  37. #endif
  38. #ifdef HAVE_SYS_IOCTL_H
  39. #include <sys/ioctl.h>
  40. #endif
  41. #ifdef HAVE_SYS_PARAM_H
  42. #include <sys/param.h>
  43. #endif
  44. #include <hyper.h>
  45. #include "urldata.h"
  46. #include "sendf.h"
  47. #include "transfer.h"
  48. #include "multiif.h"
  49. #include "progress.h"
  50. #include "content_encoding.h"
  51. #include "ws.h"
  52. /* The last 3 #include files should be in this order */
  53. #include "curl_printf.h"
  54. #include "curl_memory.h"
  55. #include "memdebug.h"
  56. typedef enum {
  57. USERDATA_NOT_SET = 0, /* for tasks with no userdata set; must be zero */
  58. USERDATA_RESP_BODY
  59. } userdata_t;
  60. size_t Curl_hyper_recv(void *userp, hyper_context *ctx,
  61. uint8_t *buf, size_t buflen)
  62. {
  63. struct Curl_easy *data = userp;
  64. struct connectdata *conn = data->conn;
  65. CURLcode result;
  66. ssize_t nread;
  67. DEBUGASSERT(conn);
  68. (void)ctx;
  69. DEBUGF(infof(data, "Curl_hyper_recv(%zu)", buflen));
  70. result = Curl_read(data, conn->sockfd, (char *)buf, buflen, &nread);
  71. if(result == CURLE_AGAIN) {
  72. /* would block, register interest */
  73. DEBUGF(infof(data, "Curl_hyper_recv(%zu) -> EAGAIN", buflen));
  74. if(data->hyp.read_waker)
  75. hyper_waker_free(data->hyp.read_waker);
  76. data->hyp.read_waker = hyper_context_waker(ctx);
  77. if(!data->hyp.read_waker) {
  78. failf(data, "Couldn't make the read hyper_context_waker");
  79. return HYPER_IO_ERROR;
  80. }
  81. return HYPER_IO_PENDING;
  82. }
  83. else if(result) {
  84. failf(data, "Curl_read failed");
  85. return HYPER_IO_ERROR;
  86. }
  87. DEBUGF(infof(data, "Curl_hyper_recv(%zu) -> %zd", buflen, nread));
  88. return (size_t)nread;
  89. }
  90. size_t Curl_hyper_send(void *userp, hyper_context *ctx,
  91. const uint8_t *buf, size_t buflen)
  92. {
  93. struct Curl_easy *data = userp;
  94. struct connectdata *conn = data->conn;
  95. CURLcode result;
  96. ssize_t nwrote;
  97. DEBUGF(infof(data, "Curl_hyper_send(%zu)", buflen));
  98. result = Curl_write(data, conn->sockfd, (void *)buf, buflen, &nwrote);
  99. if(!result && !nwrote)
  100. result = CURLE_AGAIN;
  101. if(result == CURLE_AGAIN) {
  102. DEBUGF(infof(data, "Curl_hyper_send(%zu) -> EAGAIN", buflen));
  103. /* would block, register interest */
  104. if(data->hyp.write_waker)
  105. hyper_waker_free(data->hyp.write_waker);
  106. data->hyp.write_waker = hyper_context_waker(ctx);
  107. if(!data->hyp.write_waker) {
  108. failf(data, "Couldn't make the write hyper_context_waker");
  109. return HYPER_IO_ERROR;
  110. }
  111. return HYPER_IO_PENDING;
  112. }
  113. else if(result) {
  114. failf(data, "Curl_write failed");
  115. return HYPER_IO_ERROR;
  116. }
  117. DEBUGF(infof(data, "Curl_hyper_send(%zu) -> %zd", buflen, nwrote));
  118. return (size_t)nwrote;
  119. }
  120. static int hyper_each_header(void *userdata,
  121. const uint8_t *name,
  122. size_t name_len,
  123. const uint8_t *value,
  124. size_t value_len)
  125. {
  126. struct Curl_easy *data = (struct Curl_easy *)userdata;
  127. size_t len;
  128. char *headp;
  129. CURLcode result;
  130. int writetype;
  131. if(name_len + value_len + 2 > CURL_MAX_HTTP_HEADER) {
  132. failf(data, "Too long response header");
  133. data->state.hresult = CURLE_OUT_OF_MEMORY;
  134. return HYPER_ITER_BREAK;
  135. }
  136. if(!data->req.bytecount)
  137. Curl_pgrsTime(data, TIMER_STARTTRANSFER);
  138. Curl_dyn_reset(&data->state.headerb);
  139. if(name_len) {
  140. if(Curl_dyn_addf(&data->state.headerb, "%.*s: %.*s\r\n",
  141. (int) name_len, name, (int) value_len, value))
  142. return HYPER_ITER_BREAK;
  143. }
  144. else {
  145. if(Curl_dyn_addn(&data->state.headerb, STRCONST("\r\n")))
  146. return HYPER_ITER_BREAK;
  147. }
  148. len = Curl_dyn_len(&data->state.headerb);
  149. headp = Curl_dyn_ptr(&data->state.headerb);
  150. result = Curl_http_header(data, data->conn, headp);
  151. if(result) {
  152. data->state.hresult = result;
  153. return HYPER_ITER_BREAK;
  154. }
  155. Curl_debug(data, CURLINFO_HEADER_IN, headp, len);
  156. if(!data->state.hconnect || !data->set.suppress_connect_headers) {
  157. writetype = CLIENTWRITE_HEADER;
  158. if(data->state.hconnect)
  159. writetype |= CLIENTWRITE_CONNECT;
  160. if(data->req.httpcode/100 == 1)
  161. writetype |= CLIENTWRITE_1XX;
  162. result = Curl_client_write(data, writetype, headp, len);
  163. if(result) {
  164. data->state.hresult = CURLE_ABORTED_BY_CALLBACK;
  165. return HYPER_ITER_BREAK;
  166. }
  167. }
  168. result = Curl_bump_headersize(data, len, FALSE);
  169. if(result) {
  170. data->state.hresult = result;
  171. return HYPER_ITER_BREAK;
  172. }
  173. return HYPER_ITER_CONTINUE;
  174. }
  175. static int hyper_body_chunk(void *userdata, const hyper_buf *chunk)
  176. {
  177. char *buf = (char *)hyper_buf_bytes(chunk);
  178. size_t len = hyper_buf_len(chunk);
  179. struct Curl_easy *data = (struct Curl_easy *)userdata;
  180. struct SingleRequest *k = &data->req;
  181. CURLcode result = CURLE_OK;
  182. if(0 == k->bodywrites++) {
  183. bool done = FALSE;
  184. #if defined(USE_NTLM)
  185. struct connectdata *conn = data->conn;
  186. if(conn->bits.close &&
  187. (((data->req.httpcode == 401) &&
  188. (conn->http_ntlm_state == NTLMSTATE_TYPE2)) ||
  189. ((data->req.httpcode == 407) &&
  190. (conn->proxy_ntlm_state == NTLMSTATE_TYPE2)))) {
  191. infof(data, "Connection closed while negotiating NTLM");
  192. data->state.authproblem = TRUE;
  193. Curl_safefree(data->req.newurl);
  194. }
  195. #endif
  196. if(data->state.expect100header) {
  197. Curl_expire_done(data, EXPIRE_100_TIMEOUT);
  198. if(data->req.httpcode < 400) {
  199. k->exp100 = EXP100_SEND_DATA;
  200. if(data->hyp.exp100_waker) {
  201. hyper_waker_wake(data->hyp.exp100_waker);
  202. data->hyp.exp100_waker = NULL;
  203. }
  204. }
  205. else { /* >= 4xx */
  206. k->exp100 = EXP100_FAILED;
  207. }
  208. }
  209. if(data->state.hconnect && (data->req.httpcode/100 != 2) &&
  210. data->state.authproxy.done) {
  211. done = TRUE;
  212. result = CURLE_OK;
  213. }
  214. else
  215. result = Curl_http_firstwrite(data, data->conn, &done);
  216. if(result || done) {
  217. infof(data, "Return early from hyper_body_chunk");
  218. data->state.hresult = result;
  219. return HYPER_ITER_BREAK;
  220. }
  221. }
  222. if(k->ignorebody)
  223. return HYPER_ITER_CONTINUE;
  224. if(0 == len)
  225. return HYPER_ITER_CONTINUE;
  226. Curl_debug(data, CURLINFO_DATA_IN, buf, len);
  227. result = Curl_client_write(data, CLIENTWRITE_BODY, buf, len);
  228. if(result) {
  229. data->state.hresult = result;
  230. return HYPER_ITER_BREAK;
  231. }
  232. data->req.bytecount += len;
  233. result = Curl_pgrsSetDownloadCounter(data, data->req.bytecount);
  234. if(result) {
  235. data->state.hresult = result;
  236. return HYPER_ITER_BREAK;
  237. }
  238. return HYPER_ITER_CONTINUE;
  239. }
  240. /*
  241. * Hyper does not consider the status line, the first line in an HTTP/1
  242. * response, to be a header. The libcurl API does. This function sends the
  243. * status line in the header callback. */
  244. static CURLcode status_line(struct Curl_easy *data,
  245. struct connectdata *conn,
  246. uint16_t http_status,
  247. int http_version,
  248. const uint8_t *reason, size_t rlen)
  249. {
  250. CURLcode result;
  251. size_t len;
  252. const char *vstr;
  253. int writetype;
  254. vstr = http_version == HYPER_HTTP_VERSION_1_1 ? "1.1" :
  255. (http_version == HYPER_HTTP_VERSION_2 ? "2" : "1.0");
  256. /* We need to set 'httpcodeq' for functions that check the response code in
  257. a single place. */
  258. data->req.httpcode = http_status;
  259. if(data->state.hconnect)
  260. /* CONNECT */
  261. data->info.httpproxycode = http_status;
  262. else {
  263. conn->httpversion =
  264. http_version == HYPER_HTTP_VERSION_1_1 ? 11 :
  265. (http_version == HYPER_HTTP_VERSION_2 ? 20 : 10);
  266. if(http_version == HYPER_HTTP_VERSION_1_0)
  267. data->state.httpwant = CURL_HTTP_VERSION_1_0;
  268. result = Curl_http_statusline(data, conn);
  269. if(result)
  270. return result;
  271. }
  272. Curl_dyn_reset(&data->state.headerb);
  273. result = Curl_dyn_addf(&data->state.headerb, "HTTP/%s %03d %.*s\r\n",
  274. vstr,
  275. (int)http_status,
  276. (int)rlen, reason);
  277. if(result)
  278. return result;
  279. len = Curl_dyn_len(&data->state.headerb);
  280. Curl_debug(data, CURLINFO_HEADER_IN, Curl_dyn_ptr(&data->state.headerb),
  281. len);
  282. if(!data->state.hconnect || !data->set.suppress_connect_headers) {
  283. writetype = CLIENTWRITE_HEADER|CLIENTWRITE_STATUS;
  284. result = Curl_client_write(data, writetype,
  285. Curl_dyn_ptr(&data->state.headerb), len);
  286. if(result)
  287. return result;
  288. }
  289. result = Curl_bump_headersize(data, len, FALSE);
  290. return result;
  291. }
  292. /*
  293. * Hyper does not pass on the last empty response header. The libcurl API
  294. * does. This function sends an empty header in the header callback.
  295. */
  296. static CURLcode empty_header(struct Curl_easy *data)
  297. {
  298. CURLcode result = Curl_http_size(data);
  299. if(!result) {
  300. result = hyper_each_header(data, NULL, 0, NULL, 0) ?
  301. CURLE_WRITE_ERROR : CURLE_OK;
  302. if(result)
  303. failf(data, "hyperstream: couldn't pass blank header");
  304. }
  305. return result;
  306. }
  307. CURLcode Curl_hyper_stream(struct Curl_easy *data,
  308. struct connectdata *conn,
  309. int *didwhat,
  310. bool *done,
  311. int select_res)
  312. {
  313. hyper_response *resp = NULL;
  314. uint16_t http_status;
  315. int http_version;
  316. hyper_headers *headers = NULL;
  317. hyper_body *resp_body = NULL;
  318. struct hyptransfer *h = &data->hyp;
  319. hyper_task *task;
  320. hyper_task *foreach;
  321. const uint8_t *reasonp;
  322. size_t reason_len;
  323. CURLcode result = CURLE_OK;
  324. struct SingleRequest *k = &data->req;
  325. (void)conn;
  326. if(k->exp100 > EXP100_SEND_DATA) {
  327. struct curltime now = Curl_now();
  328. timediff_t ms = Curl_timediff(now, k->start100);
  329. if(ms >= data->set.expect_100_timeout) {
  330. /* we've waited long enough, continue anyway */
  331. k->exp100 = EXP100_SEND_DATA;
  332. k->keepon |= KEEP_SEND;
  333. Curl_expire_done(data, EXPIRE_100_TIMEOUT);
  334. infof(data, "Done waiting for 100-continue");
  335. if(data->hyp.exp100_waker) {
  336. hyper_waker_wake(data->hyp.exp100_waker);
  337. data->hyp.exp100_waker = NULL;
  338. }
  339. }
  340. }
  341. if(select_res & CURL_CSELECT_IN) {
  342. if(h->read_waker)
  343. hyper_waker_wake(h->read_waker);
  344. h->read_waker = NULL;
  345. }
  346. if(select_res & CURL_CSELECT_OUT) {
  347. if(h->write_waker)
  348. hyper_waker_wake(h->write_waker);
  349. h->write_waker = NULL;
  350. }
  351. *done = FALSE;
  352. do {
  353. hyper_task_return_type t;
  354. task = hyper_executor_poll(h->exec);
  355. if(!task) {
  356. *didwhat = KEEP_RECV;
  357. break;
  358. }
  359. t = hyper_task_type(task);
  360. if(t == HYPER_TASK_ERROR) {
  361. hyper_error *hypererr = hyper_task_value(task);
  362. hyper_task_free(task);
  363. if(data->state.hresult) {
  364. /* override Hyper's view, might not even be an error */
  365. result = data->state.hresult;
  366. infof(data, "hyperstream is done (by early callback)");
  367. }
  368. else {
  369. uint8_t errbuf[256];
  370. size_t errlen = hyper_error_print(hypererr, errbuf, sizeof(errbuf));
  371. hyper_code code = hyper_error_code(hypererr);
  372. failf(data, "Hyper: [%d] %.*s", (int)code, (int)errlen, errbuf);
  373. switch(code) {
  374. case HYPERE_ABORTED_BY_CALLBACK:
  375. result = CURLE_OK;
  376. break;
  377. case HYPERE_UNEXPECTED_EOF:
  378. if(!data->req.bytecount)
  379. result = CURLE_GOT_NOTHING;
  380. else
  381. result = CURLE_RECV_ERROR;
  382. break;
  383. case HYPERE_INVALID_PEER_MESSAGE:
  384. /* bump headerbytecount to avoid the count remaining at zero and
  385. appearing to not having read anything from the peer at all */
  386. data->req.headerbytecount++;
  387. result = CURLE_UNSUPPORTED_PROTOCOL; /* maybe */
  388. break;
  389. default:
  390. result = CURLE_RECV_ERROR;
  391. break;
  392. }
  393. }
  394. *done = TRUE;
  395. hyper_error_free(hypererr);
  396. break;
  397. }
  398. else if(t == HYPER_TASK_EMPTY) {
  399. void *userdata = hyper_task_userdata(task);
  400. hyper_task_free(task);
  401. if((userdata_t)userdata == USERDATA_RESP_BODY) {
  402. /* end of transfer */
  403. *done = TRUE;
  404. infof(data, "hyperstream is done");
  405. if(!k->bodywrites) {
  406. /* hyper doesn't always call the body write callback */
  407. bool stilldone;
  408. result = Curl_http_firstwrite(data, data->conn, &stilldone);
  409. }
  410. break;
  411. }
  412. else {
  413. /* A background task for hyper; ignore */
  414. continue;
  415. }
  416. }
  417. DEBUGASSERT(HYPER_TASK_RESPONSE);
  418. resp = hyper_task_value(task);
  419. hyper_task_free(task);
  420. *didwhat = KEEP_RECV;
  421. if(!resp) {
  422. failf(data, "hyperstream: couldn't get response");
  423. return CURLE_RECV_ERROR;
  424. }
  425. http_status = hyper_response_status(resp);
  426. http_version = hyper_response_version(resp);
  427. reasonp = hyper_response_reason_phrase(resp);
  428. reason_len = hyper_response_reason_phrase_len(resp);
  429. if(http_status == 417 && data->state.expect100header) {
  430. infof(data, "Got 417 while waiting for a 100");
  431. data->state.disableexpect = TRUE;
  432. data->req.newurl = strdup(data->state.url);
  433. Curl_done_sending(data, k);
  434. }
  435. result = status_line(data, conn,
  436. http_status, http_version, reasonp, reason_len);
  437. if(result)
  438. break;
  439. headers = hyper_response_headers(resp);
  440. if(!headers) {
  441. failf(data, "hyperstream: couldn't get response headers");
  442. result = CURLE_RECV_ERROR;
  443. break;
  444. }
  445. /* the headers are already received */
  446. hyper_headers_foreach(headers, hyper_each_header, data);
  447. if(data->state.hresult) {
  448. result = data->state.hresult;
  449. break;
  450. }
  451. result = empty_header(data);
  452. if(result)
  453. break;
  454. k->deductheadercount =
  455. (100 <= http_status && 199 >= http_status)?k->headerbytecount:0;
  456. #ifdef USE_WEBSOCKETS
  457. if(k->upgr101 == UPGR101_WS) {
  458. if(http_status == 101) {
  459. /* verify the response */
  460. result = Curl_ws_accept(data, NULL, 0);
  461. if(result)
  462. return result;
  463. }
  464. else {
  465. failf(data, "Expected 101, got %u", k->httpcode);
  466. result = CURLE_HTTP_RETURNED_ERROR;
  467. break;
  468. }
  469. }
  470. #endif
  471. /* Curl_http_auth_act() checks what authentication methods that are
  472. * available and decides which one (if any) to use. It will set 'newurl'
  473. * if an auth method was picked. */
  474. result = Curl_http_auth_act(data);
  475. if(result)
  476. break;
  477. resp_body = hyper_response_body(resp);
  478. if(!resp_body) {
  479. failf(data, "hyperstream: couldn't get response body");
  480. result = CURLE_RECV_ERROR;
  481. break;
  482. }
  483. foreach = hyper_body_foreach(resp_body, hyper_body_chunk, data);
  484. if(!foreach) {
  485. failf(data, "hyperstream: body foreach failed");
  486. result = CURLE_OUT_OF_MEMORY;
  487. break;
  488. }
  489. hyper_task_set_userdata(foreach, (void *)USERDATA_RESP_BODY);
  490. if(HYPERE_OK != hyper_executor_push(h->exec, foreach)) {
  491. failf(data, "Couldn't hyper_executor_push the body-foreach");
  492. result = CURLE_OUT_OF_MEMORY;
  493. break;
  494. }
  495. hyper_response_free(resp);
  496. resp = NULL;
  497. } while(1);
  498. if(resp)
  499. hyper_response_free(resp);
  500. return result;
  501. }
  502. static CURLcode debug_request(struct Curl_easy *data,
  503. const char *method,
  504. const char *path,
  505. bool h2)
  506. {
  507. char *req = aprintf("%s %s HTTP/%s\r\n", method, path,
  508. h2?"2":"1.1");
  509. if(!req)
  510. return CURLE_OUT_OF_MEMORY;
  511. Curl_debug(data, CURLINFO_HEADER_OUT, req, strlen(req));
  512. free(req);
  513. return CURLE_OK;
  514. }
  515. /*
  516. * Given a full header line "name: value" (optional CRLF in the input, should
  517. * be in the output), add to Hyper and send to the debug callback.
  518. *
  519. * Supports multiple headers.
  520. */
  521. CURLcode Curl_hyper_header(struct Curl_easy *data, hyper_headers *headers,
  522. const char *line)
  523. {
  524. const char *p;
  525. const char *n;
  526. size_t nlen;
  527. const char *v;
  528. size_t vlen;
  529. bool newline = TRUE;
  530. int numh = 0;
  531. if(!line)
  532. return CURLE_OK;
  533. n = line;
  534. do {
  535. size_t linelen = 0;
  536. p = strchr(n, ':');
  537. if(!p)
  538. /* this is fine if we already added at least one header */
  539. return numh ? CURLE_OK : CURLE_BAD_FUNCTION_ARGUMENT;
  540. nlen = p - n;
  541. p++; /* move past the colon */
  542. while(*p == ' ')
  543. p++;
  544. v = p;
  545. p = strchr(v, '\r');
  546. if(!p) {
  547. p = strchr(v, '\n');
  548. if(p)
  549. linelen = 1; /* LF only */
  550. else {
  551. p = strchr(v, '\0');
  552. newline = FALSE; /* no newline */
  553. }
  554. }
  555. else
  556. linelen = 2; /* CRLF ending */
  557. linelen += (p - n);
  558. vlen = p - v;
  559. if(HYPERE_OK != hyper_headers_add(headers, (uint8_t *)n, nlen,
  560. (uint8_t *)v, vlen)) {
  561. failf(data, "hyper refused to add header '%s'", line);
  562. return CURLE_OUT_OF_MEMORY;
  563. }
  564. if(data->set.verbose) {
  565. char *ptr = NULL;
  566. if(!newline) {
  567. ptr = aprintf("%.*s\r\n", (int)linelen, line);
  568. if(!ptr)
  569. return CURLE_OUT_OF_MEMORY;
  570. Curl_debug(data, CURLINFO_HEADER_OUT, ptr, linelen + 2);
  571. free(ptr);
  572. }
  573. else
  574. Curl_debug(data, CURLINFO_HEADER_OUT, (char *)n, linelen);
  575. }
  576. numh++;
  577. n += linelen;
  578. } while(newline);
  579. return CURLE_OK;
  580. }
  581. static CURLcode request_target(struct Curl_easy *data,
  582. struct connectdata *conn,
  583. const char *method,
  584. bool h2,
  585. hyper_request *req)
  586. {
  587. CURLcode result;
  588. struct dynbuf r;
  589. Curl_dyn_init(&r, DYN_HTTP_REQUEST);
  590. result = Curl_http_target(data, conn, &r);
  591. if(result)
  592. return result;
  593. if(h2 && hyper_request_set_uri_parts(req,
  594. /* scheme */
  595. (uint8_t *)data->state.up.scheme,
  596. strlen(data->state.up.scheme),
  597. /* authority */
  598. (uint8_t *)conn->host.name,
  599. strlen(conn->host.name),
  600. /* path_and_query */
  601. (uint8_t *)Curl_dyn_uptr(&r),
  602. Curl_dyn_len(&r))) {
  603. failf(data, "error setting uri parts to hyper");
  604. result = CURLE_OUT_OF_MEMORY;
  605. }
  606. else if(!h2 && hyper_request_set_uri(req, (uint8_t *)Curl_dyn_uptr(&r),
  607. Curl_dyn_len(&r))) {
  608. failf(data, "error setting uri to hyper");
  609. result = CURLE_OUT_OF_MEMORY;
  610. }
  611. else
  612. result = debug_request(data, method, Curl_dyn_ptr(&r), h2);
  613. Curl_dyn_free(&r);
  614. return result;
  615. }
  616. static int uploadpostfields(void *userdata, hyper_context *ctx,
  617. hyper_buf **chunk)
  618. {
  619. struct Curl_easy *data = (struct Curl_easy *)userdata;
  620. (void)ctx;
  621. if(data->req.exp100 > EXP100_SEND_DATA) {
  622. if(data->req.exp100 == EXP100_FAILED)
  623. return HYPER_POLL_ERROR;
  624. /* still waiting confirmation */
  625. if(data->hyp.exp100_waker)
  626. hyper_waker_free(data->hyp.exp100_waker);
  627. data->hyp.exp100_waker = hyper_context_waker(ctx);
  628. return HYPER_POLL_PENDING;
  629. }
  630. if(data->req.upload_done)
  631. *chunk = NULL; /* nothing more to deliver */
  632. else {
  633. /* send everything off in a single go */
  634. hyper_buf *copy = hyper_buf_copy(data->set.postfields,
  635. (size_t)data->req.p.http->postsize);
  636. if(copy)
  637. *chunk = copy;
  638. else {
  639. data->state.hresult = CURLE_OUT_OF_MEMORY;
  640. return HYPER_POLL_ERROR;
  641. }
  642. /* increasing the writebytecount here is a little premature but we
  643. don't know exactly when the body is sent */
  644. data->req.writebytecount += (size_t)data->req.p.http->postsize;
  645. Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
  646. data->req.upload_done = TRUE;
  647. }
  648. return HYPER_POLL_READY;
  649. }
  650. static int uploadstreamed(void *userdata, hyper_context *ctx,
  651. hyper_buf **chunk)
  652. {
  653. size_t fillcount;
  654. struct Curl_easy *data = (struct Curl_easy *)userdata;
  655. struct connectdata *conn = (struct connectdata *)data->conn;
  656. CURLcode result;
  657. (void)ctx;
  658. if(data->req.exp100 > EXP100_SEND_DATA) {
  659. if(data->req.exp100 == EXP100_FAILED)
  660. return HYPER_POLL_ERROR;
  661. /* still waiting confirmation */
  662. if(data->hyp.exp100_waker)
  663. hyper_waker_free(data->hyp.exp100_waker);
  664. data->hyp.exp100_waker = hyper_context_waker(ctx);
  665. return HYPER_POLL_PENDING;
  666. }
  667. if(data->req.upload_chunky && conn->bits.authneg) {
  668. fillcount = 0;
  669. data->req.upload_chunky = FALSE;
  670. result = CURLE_OK;
  671. }
  672. else {
  673. result = Curl_fillreadbuffer(data, data->set.upload_buffer_size,
  674. &fillcount);
  675. }
  676. if(result) {
  677. data->state.hresult = result;
  678. return HYPER_POLL_ERROR;
  679. }
  680. if(!fillcount) {
  681. if((data->req.keepon & KEEP_SEND_PAUSE) != KEEP_SEND_PAUSE)
  682. /* done! */
  683. *chunk = NULL;
  684. else {
  685. /* paused, save a waker */
  686. if(data->hyp.send_body_waker)
  687. hyper_waker_free(data->hyp.send_body_waker);
  688. data->hyp.send_body_waker = hyper_context_waker(ctx);
  689. return HYPER_POLL_PENDING;
  690. }
  691. }
  692. else {
  693. hyper_buf *copy = hyper_buf_copy((uint8_t *)data->state.ulbuf, fillcount);
  694. if(copy)
  695. *chunk = copy;
  696. else {
  697. data->state.hresult = CURLE_OUT_OF_MEMORY;
  698. return HYPER_POLL_ERROR;
  699. }
  700. /* increasing the writebytecount here is a little premature but we
  701. don't know exactly when the body is sent */
  702. data->req.writebytecount += fillcount;
  703. Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
  704. }
  705. return HYPER_POLL_READY;
  706. }
  707. /*
  708. * bodysend() sets up headers in the outgoing request for an HTTP transfer that
  709. * sends a body
  710. */
  711. static CURLcode bodysend(struct Curl_easy *data,
  712. struct connectdata *conn,
  713. hyper_headers *headers,
  714. hyper_request *hyperreq,
  715. Curl_HttpReq httpreq)
  716. {
  717. struct HTTP *http = data->req.p.http;
  718. CURLcode result = CURLE_OK;
  719. struct dynbuf req;
  720. if((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD))
  721. Curl_pgrsSetUploadSize(data, 0); /* no request body */
  722. else {
  723. hyper_body *body;
  724. Curl_dyn_init(&req, DYN_HTTP_REQUEST);
  725. result = Curl_http_bodysend(data, conn, &req, httpreq);
  726. if(!result)
  727. result = Curl_hyper_header(data, headers, Curl_dyn_ptr(&req));
  728. Curl_dyn_free(&req);
  729. body = hyper_body_new();
  730. hyper_body_set_userdata(body, data);
  731. if(data->set.postfields)
  732. hyper_body_set_data_func(body, uploadpostfields);
  733. else {
  734. result = Curl_get_upload_buffer(data);
  735. if(result) {
  736. hyper_body_free(body);
  737. return result;
  738. }
  739. /* init the "upload from here" pointer */
  740. data->req.upload_fromhere = data->state.ulbuf;
  741. hyper_body_set_data_func(body, uploadstreamed);
  742. }
  743. if(HYPERE_OK != hyper_request_set_body(hyperreq, body)) {
  744. /* fail */
  745. result = CURLE_OUT_OF_MEMORY;
  746. }
  747. }
  748. http->sending = HTTPSEND_BODY;
  749. return result;
  750. }
  751. static CURLcode cookies(struct Curl_easy *data,
  752. struct connectdata *conn,
  753. hyper_headers *headers)
  754. {
  755. struct dynbuf req;
  756. CURLcode result;
  757. Curl_dyn_init(&req, DYN_HTTP_REQUEST);
  758. result = Curl_http_cookies(data, conn, &req);
  759. if(!result)
  760. result = Curl_hyper_header(data, headers, Curl_dyn_ptr(&req));
  761. Curl_dyn_free(&req);
  762. return result;
  763. }
  764. /* called on 1xx responses */
  765. static void http1xx_cb(void *arg, struct hyper_response *resp)
  766. {
  767. struct Curl_easy *data = (struct Curl_easy *)arg;
  768. hyper_headers *headers = NULL;
  769. CURLcode result = CURLE_OK;
  770. uint16_t http_status;
  771. int http_version;
  772. const uint8_t *reasonp;
  773. size_t reason_len;
  774. infof(data, "Got HTTP 1xx informational");
  775. http_status = hyper_response_status(resp);
  776. http_version = hyper_response_version(resp);
  777. reasonp = hyper_response_reason_phrase(resp);
  778. reason_len = hyper_response_reason_phrase_len(resp);
  779. result = status_line(data, data->conn,
  780. http_status, http_version, reasonp, reason_len);
  781. if(!result) {
  782. headers = hyper_response_headers(resp);
  783. if(!headers) {
  784. failf(data, "hyperstream: couldn't get 1xx response headers");
  785. result = CURLE_RECV_ERROR;
  786. }
  787. }
  788. data->state.hresult = result;
  789. if(!result) {
  790. /* the headers are already received */
  791. hyper_headers_foreach(headers, hyper_each_header, data);
  792. /* this callback also sets data->state.hresult on error */
  793. if(empty_header(data))
  794. result = CURLE_OUT_OF_MEMORY;
  795. }
  796. if(data->state.hresult)
  797. infof(data, "ERROR in 1xx, bail out");
  798. }
  799. /*
  800. * Curl_http() gets called from the generic multi_do() function when an HTTP
  801. * request is to be performed. This creates and sends a properly constructed
  802. * HTTP request.
  803. */
  804. CURLcode Curl_http(struct Curl_easy *data, bool *done)
  805. {
  806. struct connectdata *conn = data->conn;
  807. struct hyptransfer *h = &data->hyp;
  808. hyper_io *io = NULL;
  809. hyper_clientconn_options *options = NULL;
  810. hyper_task *task = NULL; /* for the handshake */
  811. hyper_task *sendtask = NULL; /* for the send */
  812. hyper_clientconn *client = NULL;
  813. hyper_request *req = NULL;
  814. hyper_headers *headers = NULL;
  815. hyper_task *handshake = NULL;
  816. CURLcode result;
  817. const char *p_accept; /* Accept: string */
  818. const char *method;
  819. Curl_HttpReq httpreq;
  820. bool h2 = FALSE;
  821. const char *te = NULL; /* transfer-encoding */
  822. hyper_code rc;
  823. /* Always consider the DO phase done after this function call, even if there
  824. may be parts of the request that is not yet sent, since we can deal with
  825. the rest of the request in the PERFORM phase. */
  826. *done = TRUE;
  827. infof(data, "Time for the Hyper dance");
  828. memset(h, 0, sizeof(struct hyptransfer));
  829. result = Curl_http_host(data, conn);
  830. if(result)
  831. return result;
  832. Curl_http_method(data, conn, &method, &httpreq);
  833. /* setup the authentication headers */
  834. {
  835. char *pq = NULL;
  836. if(data->state.up.query) {
  837. pq = aprintf("%s?%s", data->state.up.path, data->state.up.query);
  838. if(!pq)
  839. return CURLE_OUT_OF_MEMORY;
  840. }
  841. result = Curl_http_output_auth(data, conn, method, httpreq,
  842. (pq ? pq : data->state.up.path), FALSE);
  843. free(pq);
  844. if(result)
  845. return result;
  846. }
  847. result = Curl_http_resume(data, conn, httpreq);
  848. if(result)
  849. return result;
  850. result = Curl_http_range(data, httpreq);
  851. if(result)
  852. return result;
  853. result = Curl_http_useragent(data);
  854. if(result)
  855. return result;
  856. io = hyper_io_new();
  857. if(!io) {
  858. failf(data, "Couldn't create hyper IO");
  859. result = CURLE_OUT_OF_MEMORY;
  860. goto error;
  861. }
  862. /* tell Hyper how to read/write network data */
  863. hyper_io_set_userdata(io, data);
  864. hyper_io_set_read(io, Curl_hyper_recv);
  865. hyper_io_set_write(io, Curl_hyper_send);
  866. /* create an executor to poll futures */
  867. if(!h->exec) {
  868. h->exec = hyper_executor_new();
  869. if(!h->exec) {
  870. failf(data, "Couldn't create hyper executor");
  871. result = CURLE_OUT_OF_MEMORY;
  872. goto error;
  873. }
  874. }
  875. options = hyper_clientconn_options_new();
  876. if(!options) {
  877. failf(data, "Couldn't create hyper client options");
  878. result = CURLE_OUT_OF_MEMORY;
  879. goto error;
  880. }
  881. if(conn->alpn == CURL_HTTP_VERSION_2) {
  882. hyper_clientconn_options_http2(options, 1);
  883. h2 = TRUE;
  884. }
  885. hyper_clientconn_options_set_preserve_header_case(options, 1);
  886. hyper_clientconn_options_set_preserve_header_order(options, 1);
  887. hyper_clientconn_options_http1_allow_multiline_headers(options, 1);
  888. hyper_clientconn_options_exec(options, h->exec);
  889. /* "Both the `io` and the `options` are consumed in this function call" */
  890. handshake = hyper_clientconn_handshake(io, options);
  891. if(!handshake) {
  892. failf(data, "Couldn't create hyper client handshake");
  893. result = CURLE_OUT_OF_MEMORY;
  894. goto error;
  895. }
  896. io = NULL;
  897. options = NULL;
  898. if(HYPERE_OK != hyper_executor_push(h->exec, handshake)) {
  899. failf(data, "Couldn't hyper_executor_push the handshake");
  900. result = CURLE_OUT_OF_MEMORY;
  901. goto error;
  902. }
  903. handshake = NULL; /* ownership passed on */
  904. task = hyper_executor_poll(h->exec);
  905. if(!task) {
  906. failf(data, "Couldn't hyper_executor_poll the handshake");
  907. result = CURLE_OUT_OF_MEMORY;
  908. goto error;
  909. }
  910. client = hyper_task_value(task);
  911. hyper_task_free(task);
  912. req = hyper_request_new();
  913. if(!req) {
  914. failf(data, "Couldn't hyper_request_new");
  915. result = CURLE_OUT_OF_MEMORY;
  916. goto error;
  917. }
  918. if(!Curl_use_http_1_1plus(data, conn)) {
  919. if(HYPERE_OK != hyper_request_set_version(req,
  920. HYPER_HTTP_VERSION_1_0)) {
  921. failf(data, "error setting HTTP version");
  922. result = CURLE_OUT_OF_MEMORY;
  923. goto error;
  924. }
  925. }
  926. else {
  927. if(!h2 && !data->state.disableexpect) {
  928. data->state.expect100header = TRUE;
  929. }
  930. }
  931. if(hyper_request_set_method(req, (uint8_t *)method, strlen(method))) {
  932. failf(data, "error setting method");
  933. result = CURLE_OUT_OF_MEMORY;
  934. goto error;
  935. }
  936. result = request_target(data, conn, method, h2, req);
  937. if(result)
  938. goto error;
  939. headers = hyper_request_headers(req);
  940. if(!headers) {
  941. failf(data, "hyper_request_headers");
  942. result = CURLE_OUT_OF_MEMORY;
  943. goto error;
  944. }
  945. rc = hyper_request_on_informational(req, http1xx_cb, data);
  946. if(rc) {
  947. result = CURLE_OUT_OF_MEMORY;
  948. goto error;
  949. }
  950. result = Curl_http_body(data, conn, httpreq, &te);
  951. if(result)
  952. goto error;
  953. if(!h2) {
  954. if(data->state.aptr.host) {
  955. result = Curl_hyper_header(data, headers, data->state.aptr.host);
  956. if(result)
  957. goto error;
  958. }
  959. }
  960. else {
  961. /* For HTTP/2, we show the Host: header as if we sent it, to make it look
  962. like for HTTP/1 but it isn't actually sent since :authority is then
  963. used. */
  964. Curl_debug(data, CURLINFO_HEADER_OUT, data->state.aptr.host,
  965. strlen(data->state.aptr.host));
  966. }
  967. if(data->state.aptr.proxyuserpwd) {
  968. result = Curl_hyper_header(data, headers, data->state.aptr.proxyuserpwd);
  969. if(result)
  970. goto error;
  971. }
  972. if(data->state.aptr.userpwd) {
  973. result = Curl_hyper_header(data, headers, data->state.aptr.userpwd);
  974. if(result)
  975. goto error;
  976. }
  977. if((data->state.use_range && data->state.aptr.rangeline)) {
  978. result = Curl_hyper_header(data, headers, data->state.aptr.rangeline);
  979. if(result)
  980. goto error;
  981. }
  982. if(data->set.str[STRING_USERAGENT] &&
  983. *data->set.str[STRING_USERAGENT] &&
  984. data->state.aptr.uagent) {
  985. result = Curl_hyper_header(data, headers, data->state.aptr.uagent);
  986. if(result)
  987. goto error;
  988. }
  989. p_accept = Curl_checkheaders(data,
  990. STRCONST("Accept"))?NULL:"Accept: */*\r\n";
  991. if(p_accept) {
  992. result = Curl_hyper_header(data, headers, p_accept);
  993. if(result)
  994. goto error;
  995. }
  996. if(te) {
  997. result = Curl_hyper_header(data, headers, te);
  998. if(result)
  999. goto error;
  1000. }
  1001. #ifndef CURL_DISABLE_ALTSVC
  1002. if(conn->bits.altused && !Curl_checkheaders(data, STRCONST("Alt-Used"))) {
  1003. char *altused = aprintf("Alt-Used: %s:%d\r\n",
  1004. conn->conn_to_host.name, conn->conn_to_port);
  1005. if(!altused) {
  1006. result = CURLE_OUT_OF_MEMORY;
  1007. goto error;
  1008. }
  1009. result = Curl_hyper_header(data, headers, altused);
  1010. if(result)
  1011. goto error;
  1012. free(altused);
  1013. }
  1014. #endif
  1015. #ifndef CURL_DISABLE_PROXY
  1016. if(conn->bits.httpproxy && !conn->bits.tunnel_proxy &&
  1017. !Curl_checkheaders(data, STRCONST("Proxy-Connection")) &&
  1018. !Curl_checkProxyheaders(data, conn, STRCONST("Proxy-Connection"))) {
  1019. result = Curl_hyper_header(data, headers, "Proxy-Connection: Keep-Alive");
  1020. if(result)
  1021. goto error;
  1022. }
  1023. #endif
  1024. Curl_safefree(data->state.aptr.ref);
  1025. if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer"))) {
  1026. data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer);
  1027. if(!data->state.aptr.ref)
  1028. result = CURLE_OUT_OF_MEMORY;
  1029. else
  1030. result = Curl_hyper_header(data, headers, data->state.aptr.ref);
  1031. if(result)
  1032. goto error;
  1033. }
  1034. #ifdef HAVE_LIBZ
  1035. /* we only consider transfer-encoding magic if libz support is built-in */
  1036. result = Curl_transferencode(data);
  1037. if(result)
  1038. goto error;
  1039. result = Curl_hyper_header(data, headers, data->state.aptr.te);
  1040. if(result)
  1041. goto error;
  1042. #endif
  1043. if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) &&
  1044. data->set.str[STRING_ENCODING]) {
  1045. Curl_safefree(data->state.aptr.accept_encoding);
  1046. data->state.aptr.accept_encoding =
  1047. aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]);
  1048. if(!data->state.aptr.accept_encoding)
  1049. result = CURLE_OUT_OF_MEMORY;
  1050. else
  1051. result = Curl_hyper_header(data, headers,
  1052. data->state.aptr.accept_encoding);
  1053. if(result)
  1054. goto error;
  1055. }
  1056. else
  1057. Curl_safefree(data->state.aptr.accept_encoding);
  1058. result = cookies(data, conn, headers);
  1059. if(result)
  1060. goto error;
  1061. if(!result && conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS))
  1062. result = Curl_ws_request(data, headers);
  1063. result = Curl_add_timecondition(data, headers);
  1064. if(result)
  1065. goto error;
  1066. result = Curl_add_custom_headers(data, FALSE, headers);
  1067. if(result)
  1068. goto error;
  1069. result = bodysend(data, conn, headers, req, httpreq);
  1070. if(result)
  1071. goto error;
  1072. Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"\r\n", 2);
  1073. if(data->req.upload_chunky && conn->bits.authneg) {
  1074. data->req.upload_chunky = TRUE;
  1075. }
  1076. else {
  1077. data->req.upload_chunky = FALSE;
  1078. }
  1079. sendtask = hyper_clientconn_send(client, req);
  1080. if(!sendtask) {
  1081. failf(data, "hyper_clientconn_send");
  1082. result = CURLE_OUT_OF_MEMORY;
  1083. goto error;
  1084. }
  1085. req = NULL;
  1086. if(HYPERE_OK != hyper_executor_push(h->exec, sendtask)) {
  1087. failf(data, "Couldn't hyper_executor_push the send");
  1088. result = CURLE_OUT_OF_MEMORY;
  1089. goto error;
  1090. }
  1091. sendtask = NULL; /* ownership passed on */
  1092. hyper_clientconn_free(client);
  1093. client = NULL;
  1094. if((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD)) {
  1095. /* HTTP GET/HEAD download */
  1096. Curl_pgrsSetUploadSize(data, 0); /* nothing */
  1097. Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, -1);
  1098. }
  1099. conn->datastream = Curl_hyper_stream;
  1100. if(data->state.expect100header)
  1101. /* Timeout count starts now since with Hyper we don't know exactly when
  1102. the full request has been sent. */
  1103. data->req.start100 = Curl_now();
  1104. /* clear userpwd and proxyuserpwd to avoid reusing old credentials
  1105. * from reused connections */
  1106. Curl_safefree(data->state.aptr.userpwd);
  1107. Curl_safefree(data->state.aptr.proxyuserpwd);
  1108. return CURLE_OK;
  1109. error:
  1110. DEBUGASSERT(result);
  1111. if(io)
  1112. hyper_io_free(io);
  1113. if(options)
  1114. hyper_clientconn_options_free(options);
  1115. if(handshake)
  1116. hyper_task_free(handshake);
  1117. if(client)
  1118. hyper_clientconn_free(client);
  1119. if(req)
  1120. hyper_request_free(req);
  1121. return result;
  1122. }
  1123. void Curl_hyper_done(struct Curl_easy *data)
  1124. {
  1125. struct hyptransfer *h = &data->hyp;
  1126. if(h->exec) {
  1127. hyper_executor_free(h->exec);
  1128. h->exec = NULL;
  1129. }
  1130. if(h->read_waker) {
  1131. hyper_waker_free(h->read_waker);
  1132. h->read_waker = NULL;
  1133. }
  1134. if(h->write_waker) {
  1135. hyper_waker_free(h->write_waker);
  1136. h->write_waker = NULL;
  1137. }
  1138. if(h->exp100_waker) {
  1139. hyper_waker_free(h->exp100_waker);
  1140. h->exp100_waker = NULL;
  1141. }
  1142. }
  1143. #endif /* !defined(CURL_DISABLE_HTTP) && defined(USE_HYPER) */