1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-27 02:56:18 -04:00

[curl] Moved get_cached_entry to end of headers

Headers ends by CR LF.
This commit is contained in:
Witold Filipczyk 2023-07-22 22:02:27 +02:00
parent 18ba915960
commit 26190a6a26

View File

@ -310,13 +310,23 @@ http_curl_got_header(void *stream, void *buf, size_t len)
return;
}
if (len == 2 && buffer[0] == 13 && buffer[1] == 10) {
curl_easy_getinfo(http->easy, CURLINFO_RESPONSE_CODE, &http->code);
}
if (len > 0) {
add_bytes_to_string(&http->headers, buffer, len);
return;
}
if (len == 2 && buffer[0] == 13 && buffer[1] == 10) {
curl_easy_getinfo(http->easy, CURLINFO_RESPONSE_CODE, &http->code);
if (!conn->cached) {
conn->cached = get_cache_entry(conn->uri);
if (!conn->cached) {
abort_connection(conn, connection_state(S_OUT_OF_MEM));
return;
}
}
mem_free_set(&conn->cached->head, memacpy(http->headers.source, http->headers.length));
mem_free_set(&conn->cached->content_type, NULL);
}
}
@ -327,14 +337,6 @@ http_got_data(void *stream, void *buf, size_t len)
char *buffer = (char *)buf;
struct http_curl_connection_info *http = (struct http_curl_connection_info *)conn->info;
if (!conn->cached) {
conn->cached = get_cache_entry(conn->uri);
if (!conn->cached) {
abort_connection(conn, connection_state(S_OUT_OF_MEM));
return;
}
}
if (len < 0) {
abort_connection(conn, connection_state_for_errno(errno));
@ -342,10 +344,6 @@ http_got_data(void *stream, void *buf, size_t len)
}
if (len > 0) {
if (conn->from == 0) {
mem_free_set(&conn->cached->head, memacpy(http->headers.source, http->headers.length));
mem_free_set(&conn->cached->content_type, NULL);
}
if (add_fragment(conn->cached, conn->from, buffer, len) == 1) {
conn->tries = 0;
}
@ -390,14 +388,6 @@ http_curl_handle_error(struct connection *conn, CURLcode res)
struct http_curl_connection_info *http = (struct http_curl_connection_info *)conn->info;
if (url) {
if (!conn->cached) {
conn->cached = get_cache_entry(conn->uri);
if (!conn->cached) {
abort_connection(conn, connection_state(S_OUT_OF_MEM));
return;
}
}
redirect_cache(conn->cached, url, 0, 0);
abort_connection(conn, connection_state(S_OK));
return;