Skip to content

Commit 7a44d00

Browse files
committed
[core] Fetch should always end up in a callback even when response is empty
1 parent b28b492 commit 7a44d00

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/fetch.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ void Fetch::Receiver::process(Event *evt) {
5555
m_body->push(*data);
5656
}
5757
} else if (evt->is<MessageEnd>() || evt->is<StreamEnd>()) {
58-
if (m_body) {
59-
m_fetch->on_response(m_head, m_body);
60-
}
58+
m_fetch->on_response(m_head, m_body);
6159
m_head = nullptr;
6260
m_body = nullptr;
6361
}

src/main.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,21 @@ class StatusReporter : public PeriodicJob {
277277
m_url->path(),
278278
m_headers,
279279
Data::make(std::move(buffer)),
280-
[=](http::ResponseHead *head, Data *body) {
280+
[=](http::ResponseHead *head, Data *) {
281281
m_local_ip = m_fetch->outbound()->local_address()->str();
282282

283+
auto status = head ? head->status : 0;
284+
283285
// "206 Partial Content" is used by a "smart" repo
284286
// to indicate that subsequent metric reports can be incremental
285-
if (head->status != 206) {
287+
if (status != 206) {
286288
m_initial_metrics = true;
287289
}
288290

289291
Log::debug(
290292
Log::CODEBASE,
291293
"[codebase] Sent status report in %dms (size = %d, response = %d)",
292-
int(utils::now() - time), size, head->status
294+
int(utils::now() - time), size, status
293295
);
294296
}
295297
);

0 commit comments

Comments
 (0)