tool_writeout: add new writeout variable, num_headers #5947
Conversation
Where might this be useful? Who would want to know the number of headers without knowing their contents, too?
|
|
case VAR_HEADER_COUNT: | ||
{ | ||
fprintf(stream, "%ld", per->header_count); | ||
} |
bagder
Sep 9, 2020
Member
You don't need these braces.
You don't need these braces.
if(hdrcbdata->config->writeout) { | ||
char *value = NULL; | ||
|
||
value = memchr(ptr, ':', cb); |
emilengler
Sep 10, 2020
Contributor
Why do this later. You can also init at variable creation
Why do this later. You can also init at variable creation
if(outs->filename) | ||
fprintf(stream, "%s", outs->filename); | ||
if(per->outs.filename) | ||
fprintf(stream, "%s", per->outs.filename); |
emilengler
Sep 10, 2020
Contributor
You can also use fputs. I don't think it's necessary to have the printf overhead here
You can also use fputs. I don't think it's necessary to have the printf overhead here
anio
Sep 10, 2020
Author
Contributor
You are right, but this is a thing of the past and not changes I made, but I will change it.
You are right, but this is a thing of the past and not changes I made, but I will change it.
emilengler
Sep 10, 2020
Contributor
Sorry but I don't know what you mean
Sorry but I don't know what you mean
anio
Sep 11, 2020
Author
Contributor
I mean I didn't wrote fprintf(stream, "%s",
.
I mean I didn't wrote fprintf(stream, "%s",
.
emilengler
Sep 11, 2020
Contributor
Still something you can change :-)
Still something you can change :-)
I will write soon.
I think same as
Yes, after updating the JSON response to include |
You get an "empty" header last, don't you? That means the end of the headers for this response. |
Right, but how it can help when I don't know about previous responses? Do I need to count redirects? |
Shouldn't you just clear the counter when you get a new set of headers after a previous empty header? That way you'd always count only the last set. |
c2d3858
to
a88904e
|
Looks fine! How about adding a test with a redirect as well just to make sure it does the right thing then as well? |
@@ -39,6 +39,9 @@ option. (Added in 7.26.0) | |||
The initial path curl ended up in when logging on to the remote FTP | |||
server. (Added in 7.15.4) | |||
.TP | |||
.B header_count | |||
The count of retrieved headers. |
bagder
Sep 12, 2020
Member
I suggest:: "The number of response headers in the most recent request (restarted at each redirect)"
Should this mention that it doesn't include the first status line?
I suggest:: "The number of response headers in the most recent request (restarted at each redirect)"
Should this mention that it doesn't include the first status line?
anio
Sep 13, 2020
Author
Contributor
Should this mention that it doesn't include the first status line?
I think it's not necessary when we are talking about headers.
Should this mention that it doesn't include the first status line?
I think it's not necessary when we are talking about headers.
bagder
Sep 13, 2020
Member
I've just learned that some users think of that as a (special) header too.
I've just learned that some users think of that as a (special) header too.
anio
Sep 13, 2020
Author
Contributor
Oops!
By mentioning this, we also have to mention: the status line which includes the status code and reason message IS NOT a header.
So, do you prefer to mention?
Oops!
By mentioning this, we also have to mention: the status line which includes the status code and reason message IS NOT a header.
So, do you prefer to mention?
jzakrzewski
Sep 14, 2020
Contributor
I'd prefer to mention it because, as @bagder said, some treat the status line as header line (why???).
If we can be clear on the subject, that we should be.
I'd prefer to mention it because, as @bagder said, some treat the status line as header line (why???).
If we can be clear on the subject, that we should be.
bagder
Sep 14, 2020
Member
Being clear is good, which is why I brought this up to begin with.
Being clear is good, which is why I brought this up to begin with.
anio
Sep 14, 2020
Author
Contributor
OK, please give me a good sentence to add.
OK, please give me a good sentence to add.
jzakrzewski
Sep 14, 2020
Contributor
Maybe like:
"The number of response headers in the most recent request (restarted at each redirect). Note that the status line IS NOT a header."
Maybe like:
"The number of response headers in the most recent request (restarted at each redirect). Note that the status line IS NOT a header."
anio
Sep 14, 2020
Author
Contributor
Thanks! Added.
Thanks! Added.
a88904e
to
62616be
62616be
to
4711135
This variable gives the number of headers.
4711135
to
695b59b
Thanks! |
It's a draft PR.
This variable gives the number of headers. Currently it just work with disabled redirect because I didn't find out how to reset the header counter while redirect.
And also this variable is not present in JSON-formatted writeout because the JSON handler just works with curl_easy_getinfo.