5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/filesystem.h>
31 #include <epan/dfilter/dfilter.h>
33 #include "ui/follow.h"
37 sgetline(char *str
, int *next
)
41 end
= strstr(str
, "\r\n");
43 *next
= (int)strlen(str
);
47 *next
= (int)(end
-str
+2);
52 parse_http_header(char *data
, size_t len
, size_t *content_start
)
54 char *tmp
, *copy
, *line
;
59 /* XXX handle case where only partial header is passed in here.
60 * we should pass something back to indicate whether header is complete.
61 * (if not, is_gzipped is may still be unknown)
65 * In order to parse header, we duplicate data and tokenize lines.
66 * We aren't interested in actual data, so use g_strndup instead of memcpy
67 * to (possibly) copy fewer bytes (e.g., if a nul byte exists in data)
68 * This also ensures that we have a terminated string for futher processing.
70 tmp
= copy
= g_strndup(data
, len
);
76 /* skip HTTP... line*/
77 /*line = */sgetline(tmp
, &next_line
);
85 while ((line
= sgetline(tmp
, &next_line
))) {
91 if (strlen(line
) == 0) {
96 c
= strchr(line
, ':');
103 if (!strcmp(key
, "Content-Encoding") && strstr(val
, "gzip")) {
107 *content_start
= pos
;
120 * indent-tabs-mode: nil
123 * ex: set shiftwidth=4 tabstop=8 expandtab:
124 * :indentSize=4:tabSize=8:noTabs=true: