Commit b00473c
authored
Return an error rather than panicking when HeaderName is too long (#433)
Fixes #432.
This eliminates an undocumented panic from the `HeaderName` creation functions, returning instead an
`InvalidHeaderName` when the name length exceeds `MAX_HEADER_NAME_LEN`.
I considered making `InvalidHeaderName` a richer error type, but since it was already used for
another type of length error (rejecting zero-length names) I figured it was okay to reuse.
I also redefined `MAX_HEADER_NAME_LEN` slightly, so that it is equal to the largest allowed header
length, rather than one past that value. This was motivated by discovering a bug in my comparison
logic when I went to write the new test exercising the wrong-length error conditions.1 parent 975dbdd commit b00473c
2 files changed
Lines changed: 27 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | 1119 | | |
1124 | 1120 | | |
1125 | 1121 | | |
| |||
1509 | 1505 | | |
1510 | 1506 | | |
1511 | 1507 | | |
1512 | | - | |
1513 | | - | |
1514 | | - | |
1515 | | - | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
1521 | 1511 | | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
1522 | 1516 | | |
| 1517 | + | |
1523 | 1518 | | |
1524 | 1519 | | |
1525 | 1520 | | |
| |||
2156 | 2151 | | |
2157 | 2152 | | |
2158 | 2153 | | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
2159 | 2172 | | |
2160 | 2173 | | |
2161 | 2174 | | |
| |||
0 commit comments