xref: /aosp_15_r20/external/curl/docs/internals/NEW-PROTOCOL.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker<!--
2*6236dae4SAndroid Build Coastguard WorkerCopyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard Worker
4*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
5*6236dae4SAndroid Build Coastguard Worker-->
6*6236dae4SAndroid Build Coastguard Worker
7*6236dae4SAndroid Build Coastguard Worker# Adding a new protocol?
8*6236dae4SAndroid Build Coastguard Worker
9*6236dae4SAndroid Build Coastguard WorkerEvery once in a while, someone comes up with the idea of adding support for yet
10*6236dae4SAndroid Build Coastguard Workeranother protocol to curl. After all, curl already supports 25 something
11*6236dae4SAndroid Build Coastguard Workerprotocols and it is the Internet transfer machine for the world.
12*6236dae4SAndroid Build Coastguard Worker
13*6236dae4SAndroid Build Coastguard WorkerIn the curl project we love protocols and we love supporting many protocols
14*6236dae4SAndroid Build Coastguard Workerand doing it well.
15*6236dae4SAndroid Build Coastguard Worker
16*6236dae4SAndroid Build Coastguard WorkerHow do you proceed to add a new protocol and what are the requirements?
17*6236dae4SAndroid Build Coastguard Worker
18*6236dae4SAndroid Build Coastguard Worker## No fixed set of requirements
19*6236dae4SAndroid Build Coastguard Worker
20*6236dae4SAndroid Build Coastguard WorkerThis document is an attempt to describe things to consider. There is no
21*6236dae4SAndroid Build Coastguard Workerchecklist of the twenty-seven things you need to cross off. We view the entire
22*6236dae4SAndroid Build Coastguard Workereffort as a whole and then judge if it seems to be the right thing - for now.
23*6236dae4SAndroid Build Coastguard WorkerThe more things that look right, fit our patterns and are done in ways that
24*6236dae4SAndroid Build Coastguard Workeralign with our thinking, the better are the chances that we agree that
25*6236dae4SAndroid Build Coastguard Workersupporting this protocol is a grand idea.
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard Worker## Mutual benefit is preferred
28*6236dae4SAndroid Build Coastguard Worker
29*6236dae4SAndroid Build Coastguard Workercurl is not here for your protocol. Your protocol is not here for curl. The
30*6236dae4SAndroid Build Coastguard Workerbest cooperation and end result occur when all involved parties mutually see
31*6236dae4SAndroid Build Coastguard Workerand agree that supporting this protocol in curl would be good for everyone.
32*6236dae4SAndroid Build Coastguard WorkerHeck, for the world.
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard WorkerConsider "selling us" the idea that we need an implementation merged in curl,
35*6236dae4SAndroid Build Coastguard Workerto be fairly important. *Why* do we want curl to support this new protocol?
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard Worker## Protocol requirements
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard Worker### Client-side
40*6236dae4SAndroid Build Coastguard Worker
41*6236dae4SAndroid Build Coastguard WorkerThe protocol implementation is for a client's side of a "communication
42*6236dae4SAndroid Build Coastguard Workersession".
43*6236dae4SAndroid Build Coastguard Worker
44*6236dae4SAndroid Build Coastguard Worker### Transfer oriented
45*6236dae4SAndroid Build Coastguard Worker
46*6236dae4SAndroid Build Coastguard WorkerThe protocol itself should be focused on *transfers*. Be it uploads or
47*6236dae4SAndroid Build Coastguard Workerdownloads or both. It should at least be possible to view the transfers as
48*6236dae4SAndroid Build Coastguard Workersuch, like we can view reading emails over POP3 as a download and sending
49*6236dae4SAndroid Build Coastguard Workeremails over SMTP as an upload.
50*6236dae4SAndroid Build Coastguard Worker
51*6236dae4SAndroid Build Coastguard WorkerIf you cannot even shoehorn the protocol into a transfer focused view, then
52*6236dae4SAndroid Build Coastguard Workeryou are up for a tough argument.
53*6236dae4SAndroid Build Coastguard Worker
54*6236dae4SAndroid Build Coastguard Worker### URL
55*6236dae4SAndroid Build Coastguard Worker
56*6236dae4SAndroid Build Coastguard WorkerThere should be a documented URL format. If there is an RFC for it there is no
57*6236dae4SAndroid Build Coastguard Workerquestion about it but the syntax does not have to be a published RFC. It could
58*6236dae4SAndroid Build Coastguard Workerbe enough if it is already in use by other implementations.
59*6236dae4SAndroid Build Coastguard Worker
60*6236dae4SAndroid Build Coastguard WorkerIf you make up the syntax just in order to be able to propose it to curl, then
61*6236dae4SAndroid Build Coastguard Workeryou are in a bad place. URLs are designed and defined for interoperability.
62*6236dae4SAndroid Build Coastguard WorkerThere should at least be a good chance that other clients and servers can be
63*6236dae4SAndroid Build Coastguard Workerimplemented supporting the same URL syntax and work the same or similar way.
64*6236dae4SAndroid Build Coastguard Worker
65*6236dae4SAndroid Build Coastguard WorkerURLs work on registered 'schemes'. There is a register of [all officially
66*6236dae4SAndroid Build Coastguard Workerrecognized
67*6236dae4SAndroid Build Coastguard Workerschemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml). If
68*6236dae4SAndroid Build Coastguard Workeryour protocol is not in there, is it really a protocol we want?
69*6236dae4SAndroid Build Coastguard Worker
70*6236dae4SAndroid Build Coastguard Worker### Wide and public use
71*6236dae4SAndroid Build Coastguard Worker
72*6236dae4SAndroid Build Coastguard WorkerThe protocol shall already be used or have an expectation of getting used
73*6236dae4SAndroid Build Coastguard Workerwidely. Experimental protocols are better off worked on in experiments first,
74*6236dae4SAndroid Build Coastguard Workerto prove themselves before they are adopted by curl.
75*6236dae4SAndroid Build Coastguard Worker
76*6236dae4SAndroid Build Coastguard Worker## Code
77*6236dae4SAndroid Build Coastguard Worker
78*6236dae4SAndroid Build Coastguard WorkerOf course the code needs to be written, provided, licensed agreeably and it
79*6236dae4SAndroid Build Coastguard Workershould follow our code guidelines and review comments have to be dealt with.
80*6236dae4SAndroid Build Coastguard WorkerIf the implementation needs third party code, that third party code should not
81*6236dae4SAndroid Build Coastguard Workerhave noticeably lesser standards than the curl project itself.
82*6236dae4SAndroid Build Coastguard Worker
83*6236dae4SAndroid Build Coastguard Worker## Tests
84*6236dae4SAndroid Build Coastguard Worker
85*6236dae4SAndroid Build Coastguard WorkerAs much of the protocol implementation as possible needs to be verified by
86*6236dae4SAndroid Build Coastguard Workercurl test cases. We must have the implementation get tested by CI jobs,
87*6236dae4SAndroid Build Coastguard Workertorture tests and more.
88*6236dae4SAndroid Build Coastguard Worker
89*6236dae4SAndroid Build Coastguard WorkerWe have experienced many times in the past how new implementations were brought
90*6236dae4SAndroid Build Coastguard Workerto curl and immediately once the code had been merged, the originator vanished
91*6236dae4SAndroid Build Coastguard Workerfrom the face of the earth. That is fine, but we need to take the necessary
92*6236dae4SAndroid Build Coastguard Workerprecautions so when it happens we are still fine.
93*6236dae4SAndroid Build Coastguard Worker
94*6236dae4SAndroid Build Coastguard WorkerOur test infrastructure is powerful enough to test just about every possible
95*6236dae4SAndroid Build Coastguard Workerprotocol - but it might require a bit of an effort to make it happen.
96*6236dae4SAndroid Build Coastguard Worker
97*6236dae4SAndroid Build Coastguard Worker## Documentation
98*6236dae4SAndroid Build Coastguard Worker
99*6236dae4SAndroid Build Coastguard WorkerWe cannot assume that users are particularly familiar with details and
100*6236dae4SAndroid Build Coastguard Workerpeculiarities of the protocol. It needs documentation.
101*6236dae4SAndroid Build Coastguard Worker
102*6236dae4SAndroid Build Coastguard WorkerMaybe it even needs some internal documentation so that the developers who try
103*6236dae4SAndroid Build Coastguard Workerto debug something five years from now can figure out functionality a little
104*6236dae4SAndroid Build Coastguard Workereasier.
105*6236dae4SAndroid Build Coastguard Worker
106*6236dae4SAndroid Build Coastguard WorkerThe protocol specification itself should be freely available without requiring
107*6236dae4SAndroid Build Coastguard Workera non-disclosure agreement or similar.
108*6236dae4SAndroid Build Coastguard Worker
109*6236dae4SAndroid Build Coastguard Worker## Do not compare
110*6236dae4SAndroid Build Coastguard Worker
111*6236dae4SAndroid Build Coastguard WorkerWe are constantly raising the bar and we are constantly improving the project.
112*6236dae4SAndroid Build Coastguard WorkerA lot of things we did in the past would not be acceptable if done today.
113*6236dae4SAndroid Build Coastguard WorkerTherefore, you might be tempted to use shortcuts or "hacks" you can spot
114*6236dae4SAndroid Build Coastguard Workerother - existing - protocol implementations have used, but there is nothing to
115*6236dae4SAndroid Build Coastguard Workergain from that. The bar has been raised. Former "cheats" may not tolerated
116*6236dae4SAndroid Build Coastguard Workeranymore.
117