mirror of
https://github.com/curl/curl.git
synced 2026-08-06 19:06:14 +03:00
http: move headers collecting to writer
- add a client writer that does "push" response headers written to the client if the headers api is enabled - remove special handling in sendf.c - needs to be installed very early on connection setup to catch CONNECT response headers Closes #12880
This commit is contained in:
parent
5b41fac587
commit
2abfa3833b
6 changed files with 90 additions and 19 deletions
27
lib/sendf.c
27
lib/sendf.c
|
|
@ -49,7 +49,6 @@
|
|||
#include "select.h"
|
||||
#include "strdup.h"
|
||||
#include "http2.h"
|
||||
#include "headers.h"
|
||||
#include "progress.h"
|
||||
#include "ws.h"
|
||||
|
||||
|
|
@ -256,21 +255,6 @@ static CURLcode chop_write(struct Curl_easy *data,
|
|||
len -= chunklen;
|
||||
}
|
||||
|
||||
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_HEADERS_API)
|
||||
/* HTTP header, but not status-line */
|
||||
if((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
|
||||
(type & CLIENTWRITE_HEADER) && !(type & CLIENTWRITE_STATUS) ) {
|
||||
unsigned char htype = (unsigned char)
|
||||
(type & CLIENTWRITE_CONNECT ? CURLH_CONNECT :
|
||||
(type & CLIENTWRITE_1XX ? CURLH_1XX :
|
||||
(type & CLIENTWRITE_TRAILER ? CURLH_TRAILER :
|
||||
CURLH_HEADER)));
|
||||
CURLcode result = Curl_headers_push(data, optr, htype);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(writeheader) {
|
||||
size_t wrote;
|
||||
|
||||
|
|
@ -674,6 +658,17 @@ CURLcode Curl_cwriter_add(struct Curl_easy *data,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
struct Curl_cwriter *Curl_cwriter_get_by_name(struct Curl_easy *data,
|
||||
const char *name)
|
||||
{
|
||||
struct Curl_cwriter *writer;
|
||||
for(writer = data->req.writer_stack; writer; writer = writer->next) {
|
||||
if(!strcmp(name, writer->cwt->name))
|
||||
return writer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Curl_cwriter_remove_by_name(struct Curl_easy *data,
|
||||
const char *name)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue