mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
This commit is contained in:
commit
5511c5b748
3
AUTHORS
3
AUTHORS
@ -161,6 +161,9 @@ Doug Kearns <djkea2@mugca.its.monash.edu.au>
|
|||||||
Edwin Groothuis <edwin@mavetju.org>
|
Edwin Groothuis <edwin@mavetju.org>
|
||||||
Dump-width option
|
Dump-width option
|
||||||
|
|
||||||
|
Eric Wald <eswald@gmail.com>
|
||||||
|
Vim ftplugin to set ELinks coding style
|
||||||
|
|
||||||
Evan Hughes <hughes@lab43.org>
|
Evan Hughes <hughes@lab43.org>
|
||||||
Bookmarks
|
Bookmarks
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ render_dom_node_enhanced_text(struct dom_renderer *renderer, struct dom_node *no
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum dom_stack_code
|
static enum dom_stack_code
|
||||||
render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *data)
|
render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||||
{
|
{
|
||||||
struct dom_renderer *renderer = stack->current->data;
|
struct dom_renderer *renderer = stack->current->data;
|
||||||
|
@ -135,6 +135,10 @@ check_link_word(struct document *document, unsigned char *uri, int length,
|
|||||||
|
|
||||||
if (!where) return NULL;
|
if (!where) return NULL;
|
||||||
|
|
||||||
|
/* We need to reparse the URI and normalize it so that the protocol and
|
||||||
|
* host part are converted to lowercase. */
|
||||||
|
normalize_uri(NULL, where);
|
||||||
|
|
||||||
new_link = add_document_link(document, where, length, x, y);
|
new_link = add_document_link(document, where, length, x, y);
|
||||||
|
|
||||||
if (!new_link) mem_free(where);
|
if (!new_link) mem_free(where);
|
||||||
|
@ -304,7 +304,7 @@ struct dom_config_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define DOM_CONFIG(name, flag) \
|
#define DOM_CONFIG(name, flag) \
|
||||||
{ INIT_DOM_STRING(name, -1), (flag) }
|
{ STATIC_DOM_STRING(name), (flag) }
|
||||||
|
|
||||||
static struct dom_config_info dom_config_info[] = {
|
static struct dom_config_info dom_config_info[] = {
|
||||||
DOM_CONFIG("cdata-sections", DOM_CONFIG_CDATA_SECTIONS),
|
DOM_CONFIG("cdata-sections", DOM_CONFIG_CDATA_SECTIONS),
|
||||||
|
@ -55,7 +55,7 @@ static const struct dom_scan_table_info css_scan_table_info[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define CSS_STRING_MAP(str, type, family) \
|
#define CSS_STRING_MAP(str, type, family) \
|
||||||
{ INIT_DOM_STRING(str, -1), CSS_TOKEN_##type, CSS_TOKEN_##family }
|
{ STATIC_DOM_STRING(str), CSS_TOKEN_##type, CSS_TOKEN_##family }
|
||||||
|
|
||||||
static const struct dom_scanner_string_mapping css_string_mappings[] = {
|
static const struct dom_scanner_string_mapping css_string_mappings[] = {
|
||||||
CSS_STRING_MAP("Hz", FREQUENCY, DIMENSION),
|
CSS_STRING_MAP("Hz", FREQUENCY, DIMENSION),
|
||||||
|
@ -451,11 +451,11 @@ done_dom_node(struct dom_node *node)
|
|||||||
struct dom_string *
|
struct dom_string *
|
||||||
get_dom_node_name(struct dom_node *node)
|
get_dom_node_name(struct dom_node *node)
|
||||||
{
|
{
|
||||||
static struct dom_string cdata_section_str = INIT_DOM_STRING("#cdata-section", -1);
|
static struct dom_string cdata_section_str = STATIC_DOM_STRING("#cdata-section");
|
||||||
static struct dom_string comment_str = INIT_DOM_STRING("#comment", -1);
|
static struct dom_string comment_str = STATIC_DOM_STRING("#comment");
|
||||||
static struct dom_string document_str = INIT_DOM_STRING("#document", -1);
|
static struct dom_string document_str = STATIC_DOM_STRING("#document");
|
||||||
static struct dom_string document_fragment_str = INIT_DOM_STRING("#document-fragment", -1);
|
static struct dom_string document_fragment_str = STATIC_DOM_STRING("#document-fragment");
|
||||||
static struct dom_string text_str = INIT_DOM_STRING("#text", -1);
|
static struct dom_string text_str = STATIC_DOM_STRING("#text");
|
||||||
|
|
||||||
assert(node);
|
assert(node);
|
||||||
|
|
||||||
@ -521,18 +521,18 @@ get_dom_node_type_name(enum dom_node_type type)
|
|||||||
{
|
{
|
||||||
static struct dom_string dom_node_type_names[DOM_NODES] = {
|
static struct dom_string dom_node_type_names[DOM_NODES] = {
|
||||||
INIT_DOM_STRING(NULL, 0),
|
INIT_DOM_STRING(NULL, 0),
|
||||||
/* DOM_NODE_ELEMENT */ INIT_DOM_STRING("element", -1),
|
/* DOM_NODE_ELEMENT */ STATIC_DOM_STRING("element"),
|
||||||
/* DOM_NODE_ATTRIBUTE */ INIT_DOM_STRING("attribute", -1),
|
/* DOM_NODE_ATTRIBUTE */ STATIC_DOM_STRING("attribute"),
|
||||||
/* DOM_NODE_TEXT */ INIT_DOM_STRING("text", -1),
|
/* DOM_NODE_TEXT */ STATIC_DOM_STRING("text"),
|
||||||
/* DOM_NODE_CDATA_SECTION */ INIT_DOM_STRING("cdata-section", -1),
|
/* DOM_NODE_CDATA_SECTION */ STATIC_DOM_STRING("cdata-section"),
|
||||||
/* DOM_NODE_ENTITY_REFERENCE */ INIT_DOM_STRING("entity-reference", -1),
|
/* DOM_NODE_ENTITY_REFERENCE */ STATIC_DOM_STRING("entity-reference"),
|
||||||
/* DOM_NODE_ENTITY */ INIT_DOM_STRING("entity", -1),
|
/* DOM_NODE_ENTITY */ STATIC_DOM_STRING("entity"),
|
||||||
/* DOM_NODE_PROCESSING_INSTRUCTION */ INIT_DOM_STRING("proc-instruction", -1),
|
/* DOM_NODE_PROCESSING_INSTRUCTION */ STATIC_DOM_STRING("proc-instruction"),
|
||||||
/* DOM_NODE_COMMENT */ INIT_DOM_STRING("comment", -1),
|
/* DOM_NODE_COMMENT */ STATIC_DOM_STRING("comment"),
|
||||||
/* DOM_NODE_DOCUMENT */ INIT_DOM_STRING("document", -1),
|
/* DOM_NODE_DOCUMENT */ STATIC_DOM_STRING("document"),
|
||||||
/* DOM_NODE_DOCUMENT_TYPE */ INIT_DOM_STRING("document-type", -1),
|
/* DOM_NODE_DOCUMENT_TYPE */ STATIC_DOM_STRING("document-type"),
|
||||||
/* DOM_NODE_DOCUMENT_FRAGMENT */ INIT_DOM_STRING("document-fragment", -1),
|
/* DOM_NODE_DOCUMENT_FRAGMENT */ STATIC_DOM_STRING("document-fragment"),
|
||||||
/* DOM_NODE_NOTATION */ INIT_DOM_STRING("notation", -1),
|
/* DOM_NODE_NOTATION */ STATIC_DOM_STRING("notation"),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(type < DOM_NODES);
|
assert(type < DOM_NODES);
|
||||||
|
@ -67,7 +67,7 @@ struct dom_scanner_string_mapping {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define DOM_STRING_MAP(str, type, family) \
|
#define DOM_STRING_MAP(str, type, family) \
|
||||||
{ INIT_DOM_STRING(str, -1), (type), (family) }
|
{ STATIC_DOM_STRING(str), (type), (family) }
|
||||||
|
|
||||||
#define DOM_STRING_MAP_END \
|
#define DOM_STRING_MAP_END \
|
||||||
{ INIT_DOM_STRING(NULL, 0), 0, 0 }
|
{ INIT_DOM_STRING(NULL, 0), 0, 0 }
|
||||||
|
@ -28,7 +28,7 @@ get_dom_select_pseudo(struct dom_scanner_token *token)
|
|||||||
} pseudo_info[] = {
|
} pseudo_info[] = {
|
||||||
|
|
||||||
#define INIT_DOM_SELECT_PSEUDO_STRING(str, type) \
|
#define INIT_DOM_SELECT_PSEUDO_STRING(str, type) \
|
||||||
{ INIT_DOM_STRING(str, -1), DOM_SELECT_PSEUDO_##type }
|
{ STATIC_DOM_STRING(str), DOM_SELECT_PSEUDO_##type }
|
||||||
|
|
||||||
INIT_DOM_SELECT_PSEUDO_STRING("first-line", FIRST_LINE),
|
INIT_DOM_SELECT_PSEUDO_STRING("first-line", FIRST_LINE),
|
||||||
INIT_DOM_SELECT_PSEUDO_STRING("first-letter", FIRST_LETTER),
|
INIT_DOM_SELECT_PSEUDO_STRING("first-letter", FIRST_LETTER),
|
||||||
|
@ -44,7 +44,7 @@ static struct dom_scan_table_info sgml_scan_table_info[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define SGML_STRING_MAP(str, type, family) \
|
#define SGML_STRING_MAP(str, type, family) \
|
||||||
{ INIT_DOM_STRING(str, -1), SGML_TOKEN_##type, SGML_TOKEN_##family }
|
{ STATIC_DOM_STRING(str), SGML_TOKEN_##type, SGML_TOKEN_##family }
|
||||||
|
|
||||||
static struct dom_scanner_string_mapping sgml_string_mappings[] = {
|
static struct dom_scanner_string_mapping sgml_string_mappings[] = {
|
||||||
SGML_STRING_MAP("--", NOTATION_COMMENT, NOTATION),
|
SGML_STRING_MAP("--", NOTATION_COMMENT, NOTATION),
|
||||||
@ -458,7 +458,8 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
real_length = 0;
|
real_length = 0;
|
||||||
|
|
||||||
} else if (string == scanner->end) {
|
} else if (string == scanner->end) {
|
||||||
/* It is incomplete. */
|
/* It is incomplete so prevent out of bound acess to
|
||||||
|
* the scanned string. */
|
||||||
|
|
||||||
} else if (is_sgml_ident(*string)) {
|
} else if (is_sgml_ident(*string)) {
|
||||||
token->string.string = string;
|
token->string.string = string;
|
||||||
@ -467,7 +468,7 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
real_length = string - token->string.string;
|
real_length = string - token->string.string;
|
||||||
|
|
||||||
skip_sgml_space(scanner, &string);
|
skip_sgml_space(scanner, &string);
|
||||||
if (*string == '>') {
|
if (string < scanner->end && *string == '>') {
|
||||||
type = SGML_TOKEN_ELEMENT;
|
type = SGML_TOKEN_ELEMENT;
|
||||||
string++;
|
string++;
|
||||||
|
|
||||||
@ -570,7 +571,10 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
string++;
|
string++;
|
||||||
skip_sgml_space(scanner, &string);
|
skip_sgml_space(scanner, &string);
|
||||||
|
|
||||||
if (is_sgml_ident(*string)) {
|
if (string == scanner->end) {
|
||||||
|
/* Prevent out of bound access. */
|
||||||
|
|
||||||
|
} else if (is_sgml_ident(*string)) {
|
||||||
token->string.string = string;
|
token->string.string = string;
|
||||||
scan_sgml(scanner, string, SGML_CHAR_IDENT);
|
scan_sgml(scanner, string, SGML_CHAR_IDENT);
|
||||||
real_length = string - token->string.string;
|
real_length = string - token->string.string;
|
||||||
@ -634,7 +638,10 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
* For stricter parsing we should always require attribute
|
* For stricter parsing we should always require attribute
|
||||||
* values to be quoted.
|
* values to be quoted.
|
||||||
*/
|
*/
|
||||||
if (*string == '>') {
|
if (string == scanner->end) {
|
||||||
|
/* Prevent out of bound access. */
|
||||||
|
|
||||||
|
} else if (*string == '>') {
|
||||||
string++;
|
string++;
|
||||||
real_length = 0;
|
real_length = 0;
|
||||||
type = SGML_TOKEN_ELEMENT_EMPTY_END;
|
type = SGML_TOKEN_ELEMENT_EMPTY_END;
|
||||||
@ -671,7 +678,8 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
/* Force an incomplete token. */
|
/* Force an incomplete token. */
|
||||||
string = scanner->end;
|
string = scanner->end;
|
||||||
|
|
||||||
} else if (is_sgml_attribute(*string)) {
|
} else if (string < scanner->end
|
||||||
|
&& is_sgml_attribute(*string)) {
|
||||||
token->string.string++;
|
token->string.string++;
|
||||||
scan_sgml_attribute(scanner, string);
|
scan_sgml_attribute(scanner, string);
|
||||||
type = SGML_TOKEN_ATTRIBUTE;
|
type = SGML_TOKEN_ATTRIBUTE;
|
||||||
@ -683,7 +691,8 @@ scan_sgml_element_token(struct dom_scanner *scanner, struct dom_scanner_token *t
|
|||||||
type = SGML_TOKEN_IDENT;
|
type = SGML_TOKEN_IDENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_sgml_attribute(*string)) {
|
if (string < scanner->end
|
||||||
|
&& is_sgml_attribute(*string)) {
|
||||||
scan_sgml_attribute(scanner, string);
|
scan_sgml_attribute(scanner, string);
|
||||||
type = SGML_TOKEN_ATTRIBUTE;
|
type = SGML_TOKEN_ATTRIBUTE;
|
||||||
if (string[-1] == '/' && string[0] == '>') {
|
if (string[-1] == '/' && string[0] == '>') {
|
||||||
|
@ -55,10 +55,10 @@ struct sgml_node_info {
|
|||||||
{ INIT_DOM_STRING(NULL, doctype##_##nodetype##S - 1), doctype##_##nodetype##_UNKNOWN }
|
{ INIT_DOM_STRING(NULL, doctype##_##nodetype##S - 1), doctype##_##nodetype##_UNKNOWN }
|
||||||
|
|
||||||
#define SGML_NODE_INFO(doctype, nodetype, name, data) \
|
#define SGML_NODE_INFO(doctype, nodetype, name, data) \
|
||||||
{ INIT_DOM_STRING(#name, sizeof(#name) - 1), doctype##_##nodetype##_##name, data }
|
{ STATIC_DOM_STRING(#name), doctype##_##nodetype##_##name, data }
|
||||||
|
|
||||||
#define SGML_NODE_INF2(doctype, nodetype, name, ident, data) \
|
#define SGML_NODE_INF2(doctype, nodetype, name, ident, data) \
|
||||||
{ INIT_DOM_STRING(ident, sizeof(ident) - 1), doctype##_##nodetype##_##name, data }
|
{ STATIC_DOM_STRING(ident), doctype##_##nodetype##_##name, data }
|
||||||
|
|
||||||
#define SGML_NODE_INFO_TYPE(doctype, nodetype, name) doctype##_##nodetype##_##name
|
#define SGML_NODE_INFO_TYPE(doctype, nodetype, name) doctype##_##nodetype##_##name
|
||||||
|
|
||||||
|
@ -3,13 +3,22 @@
|
|||||||
|
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
|
|
||||||
|
/* For now DOM has it's own little string library. Mostly because there are
|
||||||
|
* some memory overhead associated with util/string's block-based allocation
|
||||||
|
* scheme which is optimized for building strings and quickly dispose of it.
|
||||||
|
* Also, at some point we need to switch to use mainly UTF-8 strings for DOM
|
||||||
|
* and it needs to be possible to adapt the string library to that. --jonas */
|
||||||
|
|
||||||
struct dom_string {
|
struct dom_string {
|
||||||
size_t length;
|
size_t length;
|
||||||
unsigned char *string;
|
unsigned char *string;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define INIT_DOM_STRING(strvalue, strlength) \
|
#define INIT_DOM_STRING(strvalue, strlength) \
|
||||||
{ (strlength) == -1 ? sizeof(strvalue) - 1 : (strlength), (strvalue) }
|
{ (strlength), (strvalue) }
|
||||||
|
|
||||||
|
#define STATIC_DOM_STRING(strvalue) \
|
||||||
|
{ sizeof(strvalue) - 1, (strvalue) }
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
set_dom_string(struct dom_string *string, unsigned char *value, size_t length)
|
set_dom_string(struct dom_string *string, unsigned char *value, size_t length)
|
||||||
|
@ -38,9 +38,9 @@ main(int argc, char *argv[])
|
|||||||
struct sgml_parser *parser;
|
struct sgml_parser *parser;
|
||||||
struct dom_select *select;
|
struct dom_select *select;
|
||||||
enum sgml_document_type doctype = SGML_DOCTYPE_HTML;
|
enum sgml_document_type doctype = SGML_DOCTYPE_HTML;
|
||||||
struct dom_string uri = INIT_DOM_STRING("dom://test", -1);
|
struct dom_string uri = STATIC_DOM_STRING("dom://test");
|
||||||
struct dom_string source = INIT_DOM_STRING("(no source)", -1);
|
struct dom_string source = STATIC_DOM_STRING("(no source)");
|
||||||
struct dom_string selector = INIT_DOM_STRING("(no select)", -1);
|
struct dom_string selector = STATIC_DOM_STRING("(no select)");
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
@ -267,8 +267,8 @@ main(int argc, char *argv[])
|
|||||||
int normalize = 0;
|
int normalize = 0;
|
||||||
int complete = 1;
|
int complete = 1;
|
||||||
size_t read_stdin = 0;
|
size_t read_stdin = 0;
|
||||||
struct dom_string uri = INIT_DOM_STRING("dom://test", -1);
|
struct dom_string uri = STATIC_DOM_STRING("dom://test");
|
||||||
struct dom_string source = INIT_DOM_STRING("(no source)", -1);
|
struct dom_string source = STATIC_DOM_STRING("(no source)");
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
@ -56,4 +56,9 @@ test_output_line_numbers \
|
|||||||
8' \
|
8' \
|
||||||
8
|
8
|
||||||
|
|
||||||
|
test_output_line_numbers \
|
||||||
|
'Check line numbers. (IIII)' \
|
||||||
|
$'1\r\f 2\v\n 3\r\n 4\t\f 5' \
|
||||||
|
5
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -224,12 +224,6 @@ get_cache_header_content_type(struct cache_entry *cached)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *
|
|
||||||
get_default_content_type(void)
|
|
||||||
{
|
|
||||||
return get_default_mime_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *
|
unsigned char *
|
||||||
get_content_type(struct cache_entry *cached)
|
get_content_type(struct cache_entry *cached)
|
||||||
{
|
{
|
||||||
|
@ -20,9 +20,6 @@ extern struct module mime_module;
|
|||||||
* scanning the uri for extensions. */
|
* scanning the uri for extensions. */
|
||||||
unsigned char *get_content_type(struct cache_entry *cached);
|
unsigned char *get_content_type(struct cache_entry *cached);
|
||||||
|
|
||||||
/* Default mime type */
|
|
||||||
unsigned char *get_default_content_type(void);
|
|
||||||
|
|
||||||
/* Guess content type by looking at configurations of the given @extension */
|
/* Guess content type by looking at configurations of the given @extension */
|
||||||
unsigned char *get_extension_content_type(unsigned char *extension);
|
unsigned char *get_extension_content_type(unsigned char *extension);
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "intl/gettext/libintl.h"
|
#include "intl/gettext/libintl.h"
|
||||||
#include "main/module.h"
|
#include "main/module.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
#include "mime/mime.h"
|
|
||||||
#include "network/connection.h"
|
#include "network/connection.h"
|
||||||
#include "network/socket.h"
|
#include "network/socket.h"
|
||||||
#include "osdep/osdep.h"
|
#include "osdep/osdep.h"
|
||||||
@ -181,31 +180,6 @@ end:
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *
|
|
||||||
get_content_type_uri(struct uri *uri)
|
|
||||||
{
|
|
||||||
unsigned char *extension = get_extension_from_uri(uri);
|
|
||||||
|
|
||||||
if (extension) {
|
|
||||||
unsigned char *ctype;
|
|
||||||
/* XXX: A little hack for making extension handling case
|
|
||||||
* insensitive. We could probably do it better by making
|
|
||||||
* guess_encoding() case independent the real problem however
|
|
||||||
* is with default (via option system) and mimetypes resolving
|
|
||||||
* doing that option and hash lookup will not be easy to
|
|
||||||
* convert. --jonas */
|
|
||||||
convert_to_lowercase(extension, strlen(extension));
|
|
||||||
|
|
||||||
ctype = get_extension_content_type(extension);
|
|
||||||
if (ctype && *ctype) {
|
|
||||||
return ctype;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return get_default_content_type();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#define READ_SIZE 4096
|
#define READ_SIZE 4096
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -230,13 +204,18 @@ do_fsp(struct connection *conn)
|
|||||||
FSP_FILE *file = fsp_fopen(ses, data, "r");
|
FSP_FILE *file = fsp_fopen(ses, data, "r");
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
fprintf(stderr, "%s", get_content_type_uri(uri));
|
|
||||||
fclose(stderr);
|
|
||||||
if (!file)
|
if (!file)
|
||||||
fsp_error("fsp_fopen error.");
|
fsp_error("fsp_fopen error.");
|
||||||
|
|
||||||
|
/* Use the default way to find the MIME type, so write an
|
||||||
|
* 'empty' name, since something needs to be written in order
|
||||||
|
* to avoid socket errors. */
|
||||||
|
fprintf(stderr, "%c", '\0');
|
||||||
|
fclose(stderr);
|
||||||
|
|
||||||
while ((r = fsp_fread(buf, 1, READ_SIZE, file)) > 0)
|
while ((r = fsp_fread(buf, 1, READ_SIZE, file)) > 0)
|
||||||
fwrite(buf, 1, r, stdout);
|
fwrite(buf, 1, r, stdout);
|
||||||
|
|
||||||
fsp_fclose(file);
|
fsp_fclose(file);
|
||||||
fsp_close_session(ses);
|
fsp_close_session(ses);
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -274,7 +253,6 @@ fsp_got_data(struct socket *socket, struct read_buffer *rb)
|
|||||||
static void
|
static void
|
||||||
fsp_got_header(struct socket *socket, struct read_buffer *rb)
|
fsp_got_header(struct socket *socket, struct read_buffer *rb)
|
||||||
{
|
{
|
||||||
int len = rb->length;
|
|
||||||
struct connection *conn = socket->conn;
|
struct connection *conn = socket->conn;
|
||||||
struct read_buffer *buf;
|
struct read_buffer *buf;
|
||||||
|
|
||||||
@ -286,10 +264,16 @@ fsp_got_header(struct socket *socket, struct read_buffer *rb)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
socket->state = SOCKET_END_ONCLOSE;
|
socket->state = SOCKET_END_ONCLOSE;
|
||||||
if (len <= 0) goto end;
|
|
||||||
rb->data[len] = '\0';
|
if (rb->length > 0) {
|
||||||
mem_free_set(&conn->cached->content_type, stracpy(rb->data));
|
unsigned char *ctype = memacpy(rb->data, rb->length);
|
||||||
end:
|
|
||||||
|
if (ctype && *ctype)
|
||||||
|
mem_free_set(&conn->cached->content_type, ctype);
|
||||||
|
else
|
||||||
|
mem_free_if(ctype);
|
||||||
|
}
|
||||||
|
|
||||||
buf = alloc_read_buffer(conn->data_socket);
|
buf = alloc_read_buffer(conn->data_socket);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
close(socket->fd);
|
close(socket->fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user