void WhereAmI::post_location() { // do we have the current estimate? if (current_estimated_space_name.isEmpty() || current_estimated_space_name == unknown_space_name) { qDebug () << "not posting location because no estimate"; return; } QString username; if (settings->contains (setting_username_key)) { username = settings->value(setting_username_key).toString(); } QNetworkRequest request; QString url_str = setting_server_url_value; QUrl url(url_str.append("/iamhere")); url.addQueryItem ("username", username); url.addQueryItem ("est", current_estimated_space_name); request.setUrl(url); qDebug () << "req " << url; set_network_request_headers (request); reply = networkAccessManager->get (request); connect (reply, SIGNAL(finished()), SLOT (post_response())); }
static void post_error(struct st_h2o_mruby_http_request_context_t *ctx, const char *errstr) { static const struct phr_header headers_sorted[] = {{H2O_STRLIT("content-type"), H2O_STRLIT("text/plain; charset=utf-8")}}; ctx->client = NULL; size_t errstr_len = strlen(errstr); h2o_buffer_reserve(&ctx->resp.after_closed, errstr_len); memcpy(ctx->resp.after_closed->bytes + ctx->resp.after_closed->size, errstr, errstr_len); ctx->resp.after_closed->size += errstr_len; ctx->resp.has_content = 1; post_response(ctx, 500, headers_sorted, sizeof(headers_sorted) / sizeof(headers_sorted[0])); }
static h2o_http1client_body_cb on_head(h2o_http1client_t *client, const char *errstr, int minor_version, int status, h2o_iovec_t msg, struct phr_header *headers, size_t num_headers) { struct st_h2o_mruby_http_request_context_t *ctx = client->data; if (errstr != NULL) { if (errstr != h2o_http1client_error_is_eos) { /* error */ post_error(ctx, errstr); return NULL; } /* closed without body */ ctx->client = NULL; } qsort(headers, num_headers, sizeof(headers[0]), headers_sort_cb); post_response(ctx, status, headers, num_headers); return on_body; }