comparison src/http/v3/ngx_http_v3_parse.c @ 7962:e02250b55b17 quic

HTTP/3: simplified handling return codes from parse functions.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 02 Jul 2020 20:07:24 +0300
parents 4fd709540daf
children d2f716e668e8
comparison
equal deleted inserted replaced
7961:4fd709540daf 7962:e02250b55b17
195 if (st->length-- == 0) { 195 if (st->length-- == 0) {
196 return NGX_HTTP_V3_ERR_FRAME_ERROR; 196 return NGX_HTTP_V3_ERR_FRAME_ERROR;
197 } 197 }
198 198
199 rc = ngx_http_v3_parse_header_block_prefix(c, &st->prefix, ch); 199 rc = ngx_http_v3_parse_header_block_prefix(c, &st->prefix, ch);
200
201 if (rc == NGX_AGAIN) {
202 break;
203 }
204
205 if (rc != NGX_DONE) { 200 if (rc != NGX_DONE) {
206 return rc; 201 return rc;
207 } 202 }
208 203
209 if (st->length == 0) { 204 if (st->length == 0) {
226 221
227 case sw_header_rep: 222 case sw_header_rep:
228 223
229 rc = ngx_http_v3_parse_header_rep(c, &st->header_rep, st->prefix.base, 224 rc = ngx_http_v3_parse_header_rep(c, &st->header_rep, st->prefix.base,
230 ch); 225 ch);
231 st->length--; 226
232 227 if (--st->length == 0 && rc == NGX_AGAIN) {
233 if (rc == NGX_AGAIN) { 228 return NGX_HTTP_V3_ERR_FRAME_ERROR;
234 if (st->length == 0) {
235 return NGX_HTTP_V3_ERR_FRAME_ERROR;
236 }
237
238 break;
239 } 229 }
240 230
241 if (rc != NGX_DONE) { 231 if (rc != NGX_DONE) {
242 return rc; 232 return rc;
243 } 233 }
1016 1006
1017 case sw_settings: 1007 case sw_settings:
1018 1008
1019 rc = ngx_http_v3_parse_settings(c, &st->settings, ch); 1009 rc = ngx_http_v3_parse_settings(c, &st->settings, ch);
1020 1010
1021 st->length--; 1011 if (--st->length == 0 && rc == NGX_AGAIN) {
1022 1012 return NGX_HTTP_V3_ERR_SETTINGS_ERROR;
1023 if (rc == NGX_AGAIN) {
1024 if (st->length == 0) {
1025 return NGX_HTTP_V3_ERR_SETTINGS_ERROR;
1026 }
1027
1028 break;
1029 } 1013 }
1030 1014
1031 if (rc != NGX_DONE) { 1015 if (rc != NGX_DONE) {
1032 return rc; 1016 return rc;
1033 } 1017 }
1165 switch (st->state) { 1149 switch (st->state) {
1166 1150
1167 case sw_inr: 1151 case sw_inr:
1168 1152
1169 rc = ngx_http_v3_parse_header_inr(c, &st->header, ch); 1153 rc = ngx_http_v3_parse_header_inr(c, &st->header, ch);
1170
1171 if (rc == NGX_AGAIN) {
1172 break;
1173 }
1174
1175 if (rc != NGX_DONE) { 1154 if (rc != NGX_DONE) {
1176 return rc; 1155 return rc;
1177 } 1156 }
1178 1157
1179 goto done; 1158 goto done;
1180 1159
1181 case sw_iwnr: 1160 case sw_iwnr:
1182 1161
1183 rc = ngx_http_v3_parse_header_iwnr(c, &st->header, ch); 1162 rc = ngx_http_v3_parse_header_iwnr(c, &st->header, ch);
1184
1185 if (rc == NGX_AGAIN) {
1186 break;
1187 }
1188
1189 if (rc != NGX_DONE) { 1163 if (rc != NGX_DONE) {
1190 return rc; 1164 return rc;
1191 } 1165 }
1192 1166
1193 goto done; 1167 goto done;