master
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.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 "unitcheck.h"
26#ifndef CURL_DISABLE_HTTP
27#include "urldata.h"
28#include "url.h"
30struct check1625 {
31 const char *in;
32 const char *hdr;
33 const char *extract;
34 bool expect;
35};
37static CURLcode test_unit1625(const char *arg)
38{
39 UNITTEST_BEGIN_SIMPLE
41 char *large;
42 size_t i;
43 const size_t large_value_len = MAX_HTTP_RESP_HEADER_SIZE;
44 const size_t large_prefix_len = CURL_CSTRLEN("Encoding: ");
45 const size_t large_suffix_len = CURL_CSTRLEN(", chunked");
46 static const struct check1625 list[] = {
47 /* basic case */
48 { "Encoding: gzip, chunked", "Encoding:", "chunked", TRUE },
49 /* single value */
50 { "Encoding: chunked", "Encoding:", "chunked", TRUE },
51 /* third token */
52 { "Encoding: a, b, chunked", "Encoding:", "chunked", TRUE },
53 /* fourth token */
54 { "Encoding: a, b, c, chunked", "Encoding:", "chunked", TRUE },
55 /* in middle of three tokens */
56 { "Encoding: a, chunked, ninja", "Encoding:", "chunked", TRUE },
57 /* empty incoming header */
58 { "Encoding:", "Encoding:", "chunked", FALSE },
59 /* spaces in header */
60 { "Encoding: ", "Encoding:", "chunked", FALSE },
61 /* last among several with no spaces */
62 { "Encoding: ab,cd,ef,gh,ig,kl", "Encoding:", "kl", TRUE },
63 /* double commas */
64 { "Encoding: ab,,kl", "Encoding:", "kl", TRUE },
65 /* repeated commas */
66 { "Encoding: ab,cd,,,,kl", "Encoding:", "kl", TRUE },
67 /* first token of four */
68 { "Encoding: chunked, a, b, c", "Encoding:", "chunked", TRUE },
69 /* different case */
70 { "Encoding: gzip, chunked", "Encoding:", "CHUNKED", TRUE },
71 /* another different case */
72 { "Encoding: gzip, CHUNKED", "Encoding:", "chunked", TRUE },
73 /* incoming header different case */
74 { "encoDING: gzip, CHUNKED", "encoding:", "chunked", TRUE },
75 /* incoming header upper case */
76 { "ENCODING: gzip, chunked", "encoding:", "chunked", TRUE },
77 /* the other value */
78 { "Encoding: gzip, chunked", "Encoding:", "gzip", TRUE },
79 /* without space */
80 { "Encoding: gzip,chunked", "Encoding:", "gzip", TRUE },
81 /* multiple spaces */
82 { "Encoding: gzip, chunked", "Encoding:", "chunked", TRUE },
83 /* tabs */
84 { "Encoding: gzip, \tchunked", "Encoding:", "chunked", TRUE },
85 /* end with CR */
86 { "Encoding: gzip\r\n", "Encoding:", "gzip", TRUE },
87 /* end with LF */
88 { "Encoding: gzip\n", "Encoding:", "gzip", TRUE },
89 /* end with tab */
90 { "Encoding: gzip\t", "Encoding:", "gzip", TRUE },
91 /* end with space + LF */
92 { "Encoding: gzip \n", "Encoding:", "gzip", TRUE },
93 /* missing value */
94 { "Encoding: gzip, chunked", "Encoding:", "br", FALSE },
95 /* wrong header */
96 { "Encoding: gzip, chunked", "Encodin:", "chunked", FALSE },
97 /* prefix only */
98 { "Encoding: gzip2, chunked", "Encoding:", "gzip", FALSE },
99 /* prefix with letter */
100 { "Encoding: gzipp, chunked", "Encoding:", "gzip", FALSE },
101 /* suffix only */
102 { "Encoding: agzip, chunked", "Encoding:", "gzip", FALSE },
103 /* not the right header */
104 { "Decoding: gzip, chunked", "Encoding:", "gzip", FALSE },
105 /* hyphenated */
106 { "Encoding: super-nice", "Encoding:", "super-nice", TRUE },
107 /* hyphenated second token */
108 { "Encoding: extra-good, super-nice", "Encoding:", "super-nice", TRUE },
109 /* trailing blanks after the last comma */
110 { "Encoding: gzipped, ", "Encoding:", "gzip", FALSE },
111 /* the scan must not cross into a second line */
112 { "Encoding: gzipped, \r\nEncoding: gzip, chunked", "Encoding:",
113 "chunked", FALSE },
114 };
116 for(i = 0; i < CURL_ARRAYSIZE(list); i++) {
117 bool check = Curl_compareheader(list[i].in,
118 list[i].hdr, strlen(list[i].hdr),
119 list[i].extract, strlen(list[i].extract));
120 if(check != list[i].expect) {
121 curl_mprintf("Input: %s\n"
122 "Header: %s\n"
123 "Look for: %s\n"
124 "Returned: %s\n",
125 list[i].in, list[i].hdr, list[i].extract,
126 check ? "TRUE" : "FALSE");
127 break;
128 }
129 }
131 curl_mprintf("%zu invokes\n", i);
133 if(i != CURL_ARRAYSIZE(list))
134 return CURLE_FAILED_INIT;
136 large = curlx_malloc(large_prefix_len + large_value_len +
137 large_suffix_len + 1);
138 if(!large)
139 return CURLE_OUT_OF_MEMORY;
141 memcpy(large, "Encoding: ", large_prefix_len + 1);
142 memset(&large[large_prefix_len], 'a', large_value_len);
143 memcpy(&large[large_prefix_len + large_value_len], ", chunked",
144 large_suffix_len + 1);
145 fail_unless(Curl_compareheader(large, STRCONST("Encoding:"),
146 STRCONST("chunked")),
147 "token after 300 KiB was not found");
148 curlx_free(large);
150 UNITTEST_END_SIMPLE
151}
152#else /* CURL_DISABLE_HTTP */
153static CURLcode test_unit1625(const char *arg)
154{
155 UNITTEST_BEGIN_SIMPLE
156 UNITTEST_END_SIMPLE
157}
158#endif
Diagnostics4 git calls · 31 ms
CallStatusSizeTime031 ms
discover200152 B4 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=25 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2001.8 KiB · hit25 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1869 git.response.cache=HIT git.response.duration_ms=25 git.fetch.wants=21e37370c131d2bb9625268879e75705810188e0 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1869 git.pkt.payload.max=1848 git.sideband.band1.bytes=1847 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e2e996cb8d4bc2
- Request
- a9cc7a3c…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format