* Processes a section header in a server's response and checks if it matches * `section`. If the value of `peek` is 1, the header line will be peeked (and * not consumed); if 0, the line will be consumed and the function will die if * the section header doesn't match what was expected. */
| 1495 | * the section header doesn't match what was expected. |
| 1496 | */ |
| 1497 | static int process_section_header(struct packet_reader *reader, |
| 1498 | const char *section, int peek) |
| 1499 | { |
| 1500 | int ret = 0; |
| 1501 | |
| 1502 | if (packet_reader_peek(reader) == PACKET_READ_NORMAL && |
| 1503 | !strcmp(reader->line, section)) |
| 1504 | ret = 1; |
| 1505 | |
| 1506 | if (!peek) { |
| 1507 | if (!ret) { |
| 1508 | if (reader->line) |
| 1509 | die(_("expected '%s', received '%s'"), |
| 1510 | section, reader->line); |
| 1511 | else |
| 1512 | die(_("expected '%s'"), section); |
| 1513 | } |
| 1514 | packet_reader_read(reader); |
| 1515 | } |
| 1516 | |
| 1517 | return ret; |
| 1518 | } |
| 1519 | |
| 1520 | static int process_ack(struct fetch_negotiator *negotiator, |
| 1521 | struct packet_reader *reader, |
no test coverage detected