master
1#ifndef HEADER_CURL_COOKIE_H
2#define HEADER_CURL_COOKIE_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#include "llist.h"
30struct Cookie {
31 struct Curl_llist_node node; /* for the main cookie list */
32 struct Curl_llist_node getnode; /* for getlist */
33 char *name; /* <this> = value */
34 char *value; /* name = <this> */
35 char *path; /* canonical path */
36 char *domain; /* domain = <this> */
37 curl_off_t expires; /* expires = <this> */
38 unsigned int creationtime; /* time when the cookie was written */
39 BIT(tailmatch); /* tail-match the domain name */
40 BIT(secure); /* the 'secure' keyword was used */
41 BIT(livecookie); /* updated from server, not a stored file */
42 BIT(httponly); /* the httponly directive is present */
43 BIT(prefix_secure); /* secure prefix is set */
44 BIT(prefix_host); /* host prefix is set */
45};
47/*
48 * Available cookie prefixes, as defined in
49 * draft-ietf-httpbis-rfc6265bis-02
50 */
51#define COOKIE_PREFIX__SECURE (1 << 0)
52#define COOKIE_PREFIX__HOST (1 << 1)
54#define COOKIE_HASH_SIZE 63
56struct CookieInfo {
57 /* linked lists of cookies we know of */
58 struct Curl_llist cookielist[COOKIE_HASH_SIZE];
59 curl_off_t next_expiration; /* the next time at which expiration happens */
60 unsigned int numcookies; /* number of cookies in the "jar" */
61 unsigned int lastct; /* last creation-time used in the jar */
62 BIT(running); /* state info, for cookie adding information */
63 BIT(newsession); /* new session, discard session cookies on load */
64};
66/* The maximum sizes we accept for cookies. RFC 6265 section 6.1 says
67 "general-use user agents SHOULD provide each of the following minimum
68 capabilities":
70 - At least 4096 bytes per cookie (as measured by the sum of the length of
71 the cookie's name, value, and attributes).
72 In the 6265bis draft document section 5.4 it is phrased even stronger: "If
73 the sum of the lengths of the name string and the value string is more than
74 4096 octets, abort these steps and ignore the set-cookie-string entirely."
75 */
77/** Limits for INCOMING cookies **/
79/* The longest we allow a line to be when reading a cookie from an HTTP header
80 or from a cookie jar */
81#define MAX_COOKIE_LINE 5000
83/* Maximum length of an incoming cookie name or content we deal with. Longer
84 cookies are ignored. */
85#define MAX_NAME 4096
87/* Maximum number of Set-Cookie: lines accepted in a single response. If more
88 such header lines are received, they are ignored. This value must be less
89 than 256 since an unsigned char is used to count. */
90#define MAX_SET_COOKIE_AMOUNT 50
92/** Limits for OUTGOING cookies **/
94/* Maximum size for an outgoing cookie line libcurl will use in an http
95 request. This is the default maximum length used in some versions of Apache
96 httpd. */
97#define MAX_COOKIE_HEADER_LEN 8190
99/* Maximum number of cookies libcurl will send in a single request, even if
100 there might be more cookies that match. One reason to cap the number is to
101 keep the maximum HTTP request within the maximum allowed size. */
102#define MAX_COOKIE_SEND_AMOUNT 150
104struct Curl_easy;
105struct connectdata;
107bool Curl_secure_context(struct Curl_easy *data, const char *host);
109/*
110 * Add a cookie to the internal list of cookies. The domain and path arguments
111 * are only used if the COOKIE_HTTPHEADER bit is set in the flags.
112 */
114#define COOKIE_HTTPHEADER (1<<0) /* if HTTP header-style line */
115#define COOKIE_NOEXPIRE (1<<1) /* skip remove_expired() */
116#define COOKIE_SECURE (1<<2) /* connection is over secure origin */
117#define COOKIE_NOPSL (1<<3) /* skip PSL check */
118#define COOKIE_NOSESSION (1<<6) /* drop session cookies */
120CURLcode Curl_cookie_add(struct Curl_easy *data,
121 struct CookieInfo *ci,
122 const char *lineptr,
123 const char *domain,
124 const char *path,
125 const int flags) WARN_UNUSED_RESULT;
126CURLcode Curl_cookie_getlist(struct Curl_easy *data,
127 bool *okay, const char *host,
128 struct Curl_llist *list) WARN_UNUSED_RESULT;
129void Curl_cookie_clearall(struct CookieInfo *ci);
130void Curl_cookie_clearsess(struct CookieInfo *ci);
132#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES)
133#define Curl_cookie_list(x) NULL
134#define Curl_cookie_loadfiles(x, y) CURLE_OK
135#define Curl_cookie_init() NULL
136#define Curl_cookie_run(x) Curl_nop_stmt
137#define Curl_cookie_cleanup(x) Curl_nop_stmt
138#define Curl_flush_cookies(x, y) Curl_nop_stmt
139#else
140void Curl_flush_cookies(struct Curl_easy *data, bool cleanup);
141void Curl_cookie_cleanup(struct CookieInfo *ci);
142struct CookieInfo *Curl_cookie_init(void);
143struct curl_slist *Curl_cookie_list(struct Curl_easy *data);
144CURLcode Curl_cookie_loadfiles(struct Curl_easy *data,
145 int flags) WARN_UNUSED_RESULT;
146void Curl_cookie_run(struct Curl_easy *data);
147#endif
149#endif /* HEADER_CURL_COOKIE_H */
Diagnostics4 git calls · 49 ms
CallStatusSizeTime049 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 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 · hit4 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=4 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=4 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 · hit21 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=21 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
fetch2002.4 KiB · hit24 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=24 git.response.bytes=2490 git.response.cache=HIT git.response.duration_ms=24 git.fetch.wants=973ec09547618565e9bebbd7372300876174e0f1 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=2490 git.pkt.payload.max=2469 git.sideband.band1.bytes=2468 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
- a5e19e65fd6c3cd0
- Request
- 9da7b5fd…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format