Commit cbaff4f
committed
fix(net-http): a request may be sent once, and a status code is 0..999 (#2067, #2069)
#2067 -- HttpClient sent the same HttpRequestMessage as many times as it was
asked, and a counting handler received the exact same object twice. That is not
merely untidy: the second send reuses a content object the first send may
already have consumed, and both sends share one headers map the first handler
may have mutated. .NET has refused it since its first version, and this port now
raises InvalidOperationException with .NET's own message.
The claim is atomic, not merely a flag. .NET uses an interlocked
compare-and-exchange precisely so two concurrent sends cannot both win, and
std::atomic_flag::test_and_set is the same operation. The test asserts that
rather than trusting the type name -- eight threads released at one starting
line, two hundred times. The repetition was necessary: the mutation replacing
the claim with a non-atomic read-then-set PASSED a single eight-thread round,
and only failed once the test was strengthened. That is recorded rather than
quietly tidied.
The flag belongs to the message, so a second HttpClient cannot resend it either.
MarkAsSent() is public because a custom handler invoked directly, without an
HttpClient, is a legitimate caller.
sizeof(HttpRequestMessage) grows 192 -> 200 under SA-3, pinned by the layout
probe. Consumers must rebuild; no source change is needed.
#2069 -- HttpResponseMessage accepted any number as a status code: -1, 0, 1000
and 99999 all constructed and IsSuccessStatusCode answered false for each, so a
nonsense code was indistinguishable from a real failure. Both the constructor
and the setter now validate, with .NET's two checks in .NET's order.
The bound is 999, not 599: RFC 9112 makes a status code three digits and .NET
accepts every three-digit value rather than only the registered ranges, 0
included. Both facts are asserted, so a later "tightening" cannot land quietly.
An out-of-range value never reaches the object. The wire path cannot be
affected, because parseStatusLine has required exactly three digits since #2064
-- verified before implementing, not assumed.
#2069 needed no member, and neither did #2068. The response layout static_assert
is kept and reworded to record that, since the review expected both to need one.
+1 net test, two gated pins inverted. Four mutations, all caught.
Gate: 17,238 run, 0 failed, 38 executables -- green. Downstream, measured: zero
HttpClient sites in either consumer.
SR-AUD-314 and SR-AUD-316 -> remediated. This closes the modules/net-http
review: #2067, #2068, #2069 and #2071 all landed today. Record:
docs/Migration-HttpRequestSendOnceAndStatusCodeDomain.md.1 parent 2a947c8 commit cbaff4f
8 files changed
Lines changed: 240 additions & 22 deletions
File tree
- audit
- docs
- modules/net-http
- include/System/Net/Http
- src/System/Net/Http
- tests/System/Net
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
32 | 52 | | |
33 | 53 | | |
34 | 54 | | |
| |||
94 | 114 | | |
95 | 115 | | |
96 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
97 | 136 | | |
98 | 137 | | |
99 | 138 | | |
| |||
Lines changed: 45 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
22 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
23 | 57 | | |
24 | 58 | | |
25 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
26 | 62 | | |
27 | 63 | | |
28 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
29 | 72 | | |
30 | 73 | | |
31 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
306 | 317 | | |
307 | 318 | | |
308 | 319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1888 | 1888 | | |
1889 | 1889 | | |
1890 | 1890 | | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
1891 | 1895 | | |
1892 | 1896 | | |
1893 | 1897 | | |
| |||
1899 | 1903 | | |
1900 | 1904 | | |
1901 | 1905 | | |
1902 | | - | |
1903 | | - | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
1904 | 1909 | | |
1905 | | - | |
1906 | | - | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
1907 | 1913 | | |
1908 | 1914 | | |
1909 | 1915 | | |
| |||
1930 | 1936 | | |
1931 | 1937 | | |
1932 | 1938 | | |
1933 | | - | |
1934 | | - | |
1935 | | - | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
1936 | 1945 | | |
1937 | 1946 | | |
1938 | 1947 | | |
1939 | 1948 | | |
| 1949 | + | |
1940 | 1950 | | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
1944 | 1985 | | |
1945 | 1986 | | |
1946 | 1987 | | |
| |||
2025 | 2066 | | |
2026 | 2067 | | |
2027 | 2068 | | |
2028 | | - | |
2029 | | - | |
2030 | | - | |
2031 | | - | |
2032 | | - | |
2033 | | - | |
2034 | | - | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
2035 | 2090 | | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
2036 | 2098 | | |
2037 | 2099 | | |
2038 | 2100 | | |
| |||
Binary file not shown.
0 commit comments