Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_parse.c @ 580:4d3e880ce86c NGINX_0_8_42
nginx 0.8.42
*) Change: now nginx tests locations given by regular expressions, if
request was matched exactly by a location given by a prefix string.
The previous behavior has been introduced in 0.7.1.
*) Feature: the ngx_http_scgi_module.
Thanks to Manlio Perillo.
*) Feature: a text answer may be added to a "return" directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 21 Jun 2010 00:00:00 +0400 |
parents | bc110f60c0de |
children | c456a023113c |
comparison
equal
deleted
inserted
replaced
579:c570633043e7 | 580:4d3e880ce86c |
---|---|
1316 return NGX_OK; | 1316 return NGX_OK; |
1317 } | 1317 } |
1318 | 1318 |
1319 | 1319 |
1320 ngx_int_t | 1320 ngx_int_t |
1321 ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b, | |
1322 ngx_http_status_t *status) | |
1323 { | |
1324 u_char ch; | |
1325 u_char *p; | |
1326 enum { | |
1327 sw_start = 0, | |
1328 sw_H, | |
1329 sw_HT, | |
1330 sw_HTT, | |
1331 sw_HTTP, | |
1332 sw_first_major_digit, | |
1333 sw_major_digit, | |
1334 sw_first_minor_digit, | |
1335 sw_minor_digit, | |
1336 sw_status, | |
1337 sw_space_after_status, | |
1338 sw_status_text, | |
1339 sw_almost_done | |
1340 } state; | |
1341 | |
1342 state = r->state; | |
1343 | |
1344 for (p = b->pos; p < b->last; p++) { | |
1345 ch = *p; | |
1346 | |
1347 switch (state) { | |
1348 | |
1349 /* "HTTP/" */ | |
1350 case sw_start: | |
1351 switch (ch) { | |
1352 case 'H': | |
1353 state = sw_H; | |
1354 break; | |
1355 default: | |
1356 return NGX_ERROR; | |
1357 } | |
1358 break; | |
1359 | |
1360 case sw_H: | |
1361 switch (ch) { | |
1362 case 'T': | |
1363 state = sw_HT; | |
1364 break; | |
1365 default: | |
1366 return NGX_ERROR; | |
1367 } | |
1368 break; | |
1369 | |
1370 case sw_HT: | |
1371 switch (ch) { | |
1372 case 'T': | |
1373 state = sw_HTT; | |
1374 break; | |
1375 default: | |
1376 return NGX_ERROR; | |
1377 } | |
1378 break; | |
1379 | |
1380 case sw_HTT: | |
1381 switch (ch) { | |
1382 case 'P': | |
1383 state = sw_HTTP; | |
1384 break; | |
1385 default: | |
1386 return NGX_ERROR; | |
1387 } | |
1388 break; | |
1389 | |
1390 case sw_HTTP: | |
1391 switch (ch) { | |
1392 case '/': | |
1393 state = sw_first_major_digit; | |
1394 break; | |
1395 default: | |
1396 return NGX_ERROR; | |
1397 } | |
1398 break; | |
1399 | |
1400 /* the first digit of major HTTP version */ | |
1401 case sw_first_major_digit: | |
1402 if (ch < '1' || ch > '9') { | |
1403 return NGX_ERROR; | |
1404 } | |
1405 | |
1406 state = sw_major_digit; | |
1407 break; | |
1408 | |
1409 /* the major HTTP version or dot */ | |
1410 case sw_major_digit: | |
1411 if (ch == '.') { | |
1412 state = sw_first_minor_digit; | |
1413 break; | |
1414 } | |
1415 | |
1416 if (ch < '0' || ch > '9') { | |
1417 return NGX_ERROR; | |
1418 } | |
1419 | |
1420 break; | |
1421 | |
1422 /* the first digit of minor HTTP version */ | |
1423 case sw_first_minor_digit: | |
1424 if (ch < '0' || ch > '9') { | |
1425 return NGX_ERROR; | |
1426 } | |
1427 | |
1428 state = sw_minor_digit; | |
1429 break; | |
1430 | |
1431 /* the minor HTTP version or the end of the request line */ | |
1432 case sw_minor_digit: | |
1433 if (ch == ' ') { | |
1434 state = sw_status; | |
1435 break; | |
1436 } | |
1437 | |
1438 if (ch < '0' || ch > '9') { | |
1439 return NGX_ERROR; | |
1440 } | |
1441 | |
1442 break; | |
1443 | |
1444 /* HTTP status code */ | |
1445 case sw_status: | |
1446 if (ch == ' ') { | |
1447 break; | |
1448 } | |
1449 | |
1450 if (ch < '0' || ch > '9') { | |
1451 return NGX_ERROR; | |
1452 } | |
1453 | |
1454 status->code = status->code * 10 + ch - '0'; | |
1455 | |
1456 if (++status->count == 3) { | |
1457 state = sw_space_after_status; | |
1458 status->start = p - 2; | |
1459 } | |
1460 | |
1461 break; | |
1462 | |
1463 /* space or end of line */ | |
1464 case sw_space_after_status: | |
1465 switch (ch) { | |
1466 case ' ': | |
1467 state = sw_status_text; | |
1468 break; | |
1469 case '.': /* IIS may send 403.1, 403.2, etc */ | |
1470 state = sw_status_text; | |
1471 break; | |
1472 case CR: | |
1473 state = sw_almost_done; | |
1474 break; | |
1475 case LF: | |
1476 goto done; | |
1477 default: | |
1478 return NGX_ERROR; | |
1479 } | |
1480 break; | |
1481 | |
1482 /* any text until end of line */ | |
1483 case sw_status_text: | |
1484 switch (ch) { | |
1485 case CR: | |
1486 state = sw_almost_done; | |
1487 | |
1488 break; | |
1489 case LF: | |
1490 goto done; | |
1491 } | |
1492 break; | |
1493 | |
1494 /* end of status line */ | |
1495 case sw_almost_done: | |
1496 status->end = p - 1; | |
1497 switch (ch) { | |
1498 case LF: | |
1499 goto done; | |
1500 default: | |
1501 return NGX_ERROR; | |
1502 } | |
1503 } | |
1504 } | |
1505 | |
1506 b->pos = p; | |
1507 r->state = state; | |
1508 | |
1509 return NGX_AGAIN; | |
1510 | |
1511 done: | |
1512 | |
1513 b->pos = p + 1; | |
1514 | |
1515 if (status->end == NULL) { | |
1516 status->end = p; | |
1517 } | |
1518 | |
1519 r->state = sw_start; | |
1520 | |
1521 return NGX_OK; | |
1522 } | |
1523 | |
1524 | |
1525 ngx_int_t | |
1321 ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri, | 1526 ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri, |
1322 ngx_str_t *args, ngx_uint_t *flags) | 1527 ngx_str_t *args, ngx_uint_t *flags) |
1323 { | 1528 { |
1324 u_char ch, *p; | 1529 u_char ch, *p; |
1325 size_t len; | 1530 size_t len; |