Skip to content

Commit

Permalink
http: refresh config #2
Browse files Browse the repository at this point in the history
Change-Id: Ida0e4768bd300a4f11a09c8c66a2dbb062f7ff01
  • Loading branch information
mnunberg committed Feb 1, 2014
1 parent 8d397b6 commit 8c28848
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,31 @@ void lcb_setup_lcb_http_resp_t(lcb_http_resp_t *resp,
resp->v.v0.nbytes = nbytes;
}

static void maybe_refresh_config(lcb_http_request_t req, lcb_error_t err)
{

if (!req->parser) {
return;
}

if (err != LCB_SUCCESS) {
lcb_bootstrap_refresh(req->instance);
return;
}

if (req->parser->status_code >= 200 && req->parser->status_code < 299) {
return;
}

lcb_bootstrap_refresh(req->instance);
}

void lcb_http_request_finish(lcb_t instance,
lcb_http_request_t req,
lcb_error_t error)
{
if (error != LCB_SUCCESS && req->reqtype == LCB_HTTP_TYPE_VIEW) {
lcb_bootstrap_refresh(instance);
}

maybe_refresh_config(req, error);

if ((req->status & LCB_HTREQ_S_CBINVOKED) == 0 && req->on_complete) {
lcb_http_resp_t resp;
Expand Down

0 comments on commit 8c28848

Please sign in to comment.