cloud_blob_properties blob_response_parsers::parse_blob_properties(const web::http::http_response& response)
    {
        cloud_blob_properties properties;

        properties.m_etag = parse_etag(response);
        properties.m_last_modified = parse_last_modified(response);
        properties.m_lease_status = parse_lease_status(response);
        properties.m_lease_state = parse_lease_state(response);
        properties.m_lease_duration = parse_lease_duration(response);
        properties.m_size = parse_blob_size(response);

        auto& headers = response.headers();
        properties.m_page_blob_sequence_number = utility::conversions::scan_string<int64_t>(get_header_value(headers, ms_header_blob_sequence_number));
        properties.m_append_blob_committed_block_count = utility::conversions::scan_string<int>(get_header_value(headers, ms_header_blob_committed_block_count));
        properties.m_cache_control = get_header_value(headers, web::http::header_names::cache_control);
        properties.m_content_disposition = get_header_value(headers, header_content_disposition);
        properties.m_content_encoding = get_header_value(headers, web::http::header_names::content_encoding);
        properties.m_content_language = get_header_value(headers, web::http::header_names::content_language);
        properties.m_content_type = get_header_value(headers, web::http::header_names::content_type);
        properties.m_type = parse_blob_type(get_header_value(headers, ms_header_blob_type));
        properties.m_content_md5 = get_header_value(headers, ms_header_blob_content_md5);
        if (properties.m_content_md5.empty())
        {
            properties.m_content_md5 = get_header_value(headers, web::http::header_names::content_md5);
        }

        properties.m_server_encrypted = response_parsers::parse_boolean(get_header_value(headers, ms_header_server_encrypted));
        properties.m_is_incremental_copy = response_parsers::parse_boolean(get_header_value(headers, ms_header_incremental_copy));

        return properties;
    }
 cloud_blob_container_properties blob_response_parsers::parse_blob_container_properties(const web::http::http_response& response)
 {
     cloud_blob_container_properties properties;
     properties.m_etag = parse_etag(response);
     properties.m_last_modified = parse_last_modified(response);
     properties.m_lease_status = parse_lease_status(response);
     properties.m_lease_state = parse_lease_state(response);
     properties.m_lease_duration = parse_lease_duration(response);
     properties.m_public_access = parse_public_access_type(response);
     return properties;
 }
예제 #3
0
void run(void)
{
    memset(etag_last, 0, sizeof (etag_last));

    while (1) { 
        struct http_req * http;

        /* The first time coming if there's no etag is set. */
        if (0 == strcmp(etag_last, "")) {
            http = curl_perform(GIT_EVENT_API_URL, NULL);
        } else {
            /* Other times set the ETag header to check for 304 Notified in the response. */
            struct curl_slist * slist = NULL;
            char reqbuf[256];

            snprintf(reqbuf, 256, "If-None-Match: %s", etag_last);
            slist = curl_slist_append(slist, reqbuf); 
            http = curl_perform(GIT_EVENT_API_URL, slist);
        }

        if (http == NULL || http->body == NULL || http->header == NULL)
            goto SKIP;

        parse_etag(http->header);

        if (!strstr(http->header, "304 Not Modified")) {
            char message[510];
            struct channel_t ** iterator;

            message[0] = 0;

            parse_json_event(http->body, message);
            if (message[0] && plugin->irc->channels_v != NULL) {
                for (iterator = plugin->irc->channels_v; *iterator != NULL; iterator++) {
                    char * channel = (*iterator)->name;
                    char response[512];

                    sprintf(response, "PRIVMSG %s :%s\r\n", channel, message);
                    plugin->send_message(plugin->irc, response);
                }
            }
        } 

        if (http->header != NULL) free(http->header);
        if (http->body != NULL) free(http->body);
        if (http != NULL) free(http);

SKIP:
        debug("I'm polling every %d seconds as per github wants me to.\n", x_rate_limit);
        usleep(x_rate_limit *1000*1000);
    }
}