1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

content encoding: New function accept_encoding_header.

This commit is contained in:
Witold Filipczyk 2008-02-18 14:30:49 +01:00 committed by Kalle Olavi Niemitalo
parent 8492e6b1af
commit 902522fbdf
3 changed files with 31 additions and 18 deletions

View File

@ -344,3 +344,30 @@ read_encoded_file(struct string *filename, struct string *page)
close(fd);
return state;
}
void
accept_encoding_header(struct string *header)
{
#if defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || defined(CONFIG_LZMA)
int comma = 0;
add_to_string(header, "Accept-Encoding: ");
#ifdef CONFIG_BZIP2
add_to_string(header, "bzip2");
comma = 1;
#endif
#ifdef CONFIG_GZIP
if (comma) add_to_string(header, ", ");
add_to_string(header, "deflate, gzip");
comma = 1;
#endif
#ifdef CONFIG_LZMA
if (comma) add_to_string(header, ", ");
add_to_string(header, "lzma");
#endif
add_crlf_to_string(header);
#endif
}

View File

@ -45,4 +45,6 @@ read_file(struct stream_encoded *stream, int readsize, struct string *page);
/* Reads the file with the given @filename into the string @source. */
enum connection_state read_encoded_file(struct string *filename, struct string *source);
void accept_encoding_header(struct string *header);
#endif

View File

@ -23,6 +23,7 @@
#include "cache/cache.h"
#include "config/options.h"
#include "cookies/cookies.h"
#include "encoding/encoding.h"
#include "intl/charsets.h"
#include "intl/gettext/libintl.h"
#include "main/module.h"
@ -745,24 +746,7 @@ http_send_header(struct socket *socket)
add_to_string(&header, "Accept: */*");
add_crlf_to_string(&header);
/* TODO: Make this encoding.c function. */
#if defined(CONFIG_GZIP) || defined(CONFIG_BZIP2)
add_to_string(&header, "Accept-Encoding: ");
#ifdef CONFIG_BZIP2
add_to_string(&header, "bzip2");
#endif
#ifdef CONFIG_GZIP
#ifdef CONFIG_BZIP2
add_to_string(&header, ", ");
#endif
add_to_string(&header, "deflate, gzip");
#endif
add_crlf_to_string(&header);
#endif
accept_encoding_header(&header);
if (!accept_charset) {
init_accept_charset();