void 
client_delete_object_group(oss_client_t *client,
		const char *bucket_name,
		const char *key,
		unsigned short *retcode)
{
	assert(client != NULL);
	assert(bucket_name != NULL);
	assert(key != NULL);

	curl_request_param_t *user_data = (curl_request_param_t *)malloc(sizeof(curl_request_param_t));
	user_data->send_buffer = NULL;


	user_data->recv_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
	user_data->recv_buffer->ptr = (char *)malloc(sizeof(char) * 128 * 1024);
	user_data->recv_buffer->fp = NULL;
	user_data->recv_buffer->left = 128 * 1024;
	user_data->recv_buffer->allocated = 128 * 1024;

	user_data->header_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
	user_data->header_buffer->ptr = (char *)malloc(sizeof(char) * 4 * 1024);
	user_data->header_buffer->fp = NULL;
	user_data->header_buffer->left = 4 * 1024;
	user_data->header_buffer->allocated = 4 * 1024;

	unsigned int bucket_name_len = strlen(bucket_name);
	unsigned int key_len = strlen(key);
	char *resource = (char *)malloc(
			sizeof(char) * (bucket_name_len + key_len) + 16);
	char *url = (char *)malloc(sizeof(char) *
			(bucket_name_len + key_len + strlen(client->endpoint) + 64));
	char header_host[256]  = {0};
	char header_date[48]  = {0};
	char header_auth[128] = {0};
	char *now;
	unsigned int sign_len = 0;
	oss_map_t *default_headers = oss_map_new(16);

	/**
	 * 构造参数,resource,url 赋值,
	 * */
	sprintf(resource, "/%s/%s", bucket_name, key);
	sprintf(url, "%s/%s/%s", client->endpoint, bucket_name, key);
	sprintf(header_host, "Host: %s", client->endpoint);
	now = (char *)oss_get_gmt_time();
	sprintf(header_date, "Date: %s", now);

	/**
	 * 请求头部构造
	 */
	oss_map_put(default_headers, OSS_DATE, now);
	
	/**
	 * 生成签名值
	 */
	char *sign = (char *)generate_authentication(client->access_key, OSS_HTTP_DELETE,
			default_headers, NULL, resource, &sign_len);
	sprintf(header_auth, "Authorization: OSS %s:%s", client->access_id, sign);
	/**
	 * 自定义 HTTP 请求头部
	 */
	struct curl_slist *http_headers = NULL;

	http_headers = curl_slist_append(http_headers, header_host);
	http_headers = curl_slist_append(http_headers, header_date);
	http_headers = curl_slist_append(http_headers, header_auth);

	/**
	 * 发送请求
	 */
	object_group_curl_operation(OSS_HTTP_DELETE, resource, url, http_headers, user_data);

	/**
	 * 释放 http_headers资源
	 */
	curl_slist_free_all(http_headers);

	oss_map_delete(default_headers);
	if(now != NULL) {
		free(now);
		now = NULL;
	}
	if(sign != NULL) {
		free(sign);
		sign = NULL;
	}
	if(resource != NULL) {
		free(resource);
		resource = NULL;
	}
	if(url != NULL) {
		free(url);
		url = NULL;
	}
	if (user_data->header_buffer->code != 204) {
		if (retcode != NULL)
			*retcode = oss_get_retcode_from_response(user_data->recv_buffer->ptr);
	} else {
		if (retcode != NULL) *retcode = NO_CONTENT;
	}
	oss_free_user_data(user_data);
}
oss_post_object_group_result_t *
client_post_object_group(oss_client_t *client,
		oss_post_object_group_request_t *request,
		unsigned short *retcode)
{
	assert(client != NULL);
	assert(request != NULL);

	curl_request_param_t *user_data = (curl_request_param_t *)malloc(sizeof(curl_request_param_t));
	user_data->send_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
	//user_data->send_buffer->ptr = (char *)malloc(sizeof(char) * 128 * 1024);
	user_data->send_buffer->fp = NULL;


	user_data->recv_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
	user_data->recv_buffer->ptr = (char *)malloc(sizeof(char) * MAX_RECV_BUFFER_SIZE);
	user_data->recv_buffer->fp = NULL;
	user_data->recv_buffer->left = MAX_RECV_BUFFER_SIZE;
	user_data->recv_buffer->allocated = MAX_RECV_BUFFER_SIZE;

	user_data->header_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
	user_data->header_buffer->ptr = (char *)malloc(sizeof(char) * MAX_HEADER_BUFFER_SIZE);
	user_data->header_buffer->fp = NULL;
	user_data->header_buffer->left = MAX_HEADER_BUFFER_SIZE;
	user_data->header_buffer->allocated = MAX_HEADER_BUFFER_SIZE;

	unsigned int bucket_name_len = strlen(request->bucket_name);
	unsigned int key_len = strlen(request->key);
	char *resource = (char *)malloc(sizeof(char) * (bucket_name_len + key_len) + 16);
	char *url = (char *)malloc(sizeof(char) *
			(bucket_name_len + key_len + strlen(client->endpoint) + 32));

	char header_host[256]  = {0};
	char header_date[48]  = {0};
	char header_auth[128] = {0};
	char *now;
	char part[256] = {0};
	unsigned int sign_len = 0;
	int parts = 0;
	unsigned int i = 0;

	oss_map_t *default_headers = oss_map_new(16);
	/**
	 * 构造参数,resource,url 赋值,
	 * */
	sprintf(resource, "/%s/%s?group", request->get_bucket_name(request),
			request->get_key(request));
	sprintf(url, "%s/%s/%s?group", client->endpoint, request->get_bucket_name(request),
			request->get_key(request));
	sprintf(header_host, "Host: %s", client->endpoint);
	now = (char *)oss_get_gmt_time();
	sprintf(header_date, "Date: %s", now);

	/**
	 * 请求头部构造
	 */
	oss_map_put(default_headers, OSS_DATE, now);
	oss_map_put(default_headers, OSS_CONTENT_TYPE, "application/x-www-form-urlencoded");
	
	/**
	 * 生成签名值
	 */
	char *sign = (char *)generate_authentication(client->access_key, OSS_HTTP_POST,
			default_headers, NULL, resource, &sign_len);

	sprintf(header_auth, "Authorization: OSS %s:%s", client->access_id, sign);

	oss_object_group_item_t **part_item = request->get_items(request, &parts);
	tstring_t *tstr_part_item = 
		tstring_new("<CreateFileGroup>");
	for (; i < parts; i++) {
		sprintf(part, "<Part><PartNumber>%d</PartNumber><PartName>%s</PartName><ETag>%s</ETag></Part>",
				(*(part_item + i))->get_part_number(*(part_item + i)),
				(*(part_item + i))->get_part_name(*(part_item + i)),
				(*(part_item + i))->get_etag(*(part_item + i)));
		tstring_append(tstr_part_item, part);
	}
	tstring_append(tstr_part_item, "</CreateFileGroup>\n");
	unsigned int tmp_len = strlen(tstring_data(tstr_part_item));
	char *tmp = (char *)malloc(sizeof(char) * (tmp_len + 1));
	strncpy(tmp, tstring_data(tstr_part_item), tmp_len);
	tmp[tmp_len] = '\0';

	user_data->send_buffer->ptr = tmp;
	//user_data->send_buffer->ptr = (char *)(tstring_data(tstr_part_item));
	user_data->send_buffer->left = tstring_size(tstr_part_item);
	user_data->send_buffer->allocated = tstring_size(tstr_part_item);
	/**
	 * 自定义 HTTP 请求头部
	 */
	struct curl_slist *http_headers = NULL;

	http_headers = curl_slist_append(http_headers, header_host);
	http_headers = curl_slist_append(http_headers, header_date);
	http_headers = curl_slist_append(http_headers, header_auth);

	/**
	 * 发送请求
	 */
	object_group_curl_operation(OSS_HTTP_POST, resource, url, http_headers, user_data);

	/**
	 * 释放 http_headers资源
	 */
	curl_slist_free_all(http_headers);
	tstring_free(tstr_part_item);
	oss_map_delete(default_headers);
	if(now != NULL) {
		free(now);
		now = NULL;
	}
	if(sign != NULL) {
		free(sign);
		sign = NULL;
	}
	if(resource != NULL) {
		free(resource);
		resource = NULL;
	}
	if(url != NULL) {
		free(url);
		url = NULL;
	}
	if (user_data->header_buffer->code != 200) {
		if (retcode != NULL)
			*retcode = oss_get_retcode_from_response(user_data->recv_buffer->ptr);
		oss_free_user_data(user_data);
		return NULL;
	} else {
		if (retcode != NULL) *retcode = 0;
		return construct_post_object_group_response(user_data);
	}
}
oss_object_metadata_t *
client_get_object_group_to_buffer(oss_client_t *client,
		oss_get_object_group_request_t *request,
		void **output,
		unsigned int *output_len,
		unsigned short *retcode)
{

	assert(client != NULL);
	assert(request != NULL);

	curl_request_param_t *user_data = 
		(curl_request_param_t *)malloc(sizeof(curl_request_param_t));

	user_data->send_buffer = NULL; /** 发送缓冲区设置为NULL*/
	
	user_data->recv_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
	user_data->recv_buffer->ptr = NULL;
	user_data->recv_buffer->left = 0;
	user_data->recv_buffer->allocated = 0;

	user_data->header_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
	user_data->header_buffer->ptr = (char *)malloc(sizeof(char) * MAX_HEADER_BUFFER_SIZE);
	user_data->header_buffer->fp = NULL;
	user_data->header_buffer->left = MAX_HEADER_BUFFER_SIZE;
	user_data->header_buffer->allocated = MAX_HEADER_BUFFER_SIZE;
	memset(user_data->header_buffer->ptr, 0, MAX_HEADER_BUFFER_SIZE);

	unsigned int bucket_name_len = strlen(request->get_bucket_name(request));
	unsigned int key_len = strlen(request->get_key(request));
	unsigned int sign_len = 0;
	long start = 0; /**< Range 起始字节位置*/
	long length = 0; /**< Range 长度*/
	char *resource = (char *)malloc(sizeof(char) * (bucket_name_len + key_len + 16));
	char *url = (char *)malloc(sizeof(char) * (bucket_name_len + key_len + 64));
	char header_host[256]  = {0};
	char header_date[48]  = {0};
	char *now; /**< Fri, 24 Feb 2012 02:58:28 GMT */
	char header_auth[128] = {0};
	char header_if_modified_since[64] = {0};
	char header_if_unmodified_since[64] = {0};
	char header_range[64] = {0};	
	oss_map_t *default_headers = oss_map_new(16);

	/**
	 * 构造参数,resource,url 赋值
	 * */
	sprintf(resource, "/%s/%s", request->get_bucket_name(request),
			request->get_key(request));
	sprintf(url, "%s/%s/%s", client->endpoint, request->get_bucket_name(request),
			request->get_key(request));
	now = (char *)oss_get_gmt_time();
	/** 构造请求头部 */
	sprintf(header_host, "Host: %s", client->endpoint);
	sprintf(header_date, "Date: %s", now);
	oss_map_put(default_headers, OSS_DATE, now);
	/**
	 * 生成签名值
	 */
	char *sign = (char *)generate_authentication(client->access_key, OSS_HTTP_GET,
			default_headers, NULL, resource, &sign_len);
	sprintf(header_auth, "Authorization: OSS %s:%s", client->access_id, sign);

	/**
	 * 自定义 HTTP 请求头部,
	 * TODO:后续版本应支持If-Matching,If-None-Matching
	 */
	struct curl_slist *http_headers = NULL;
	
	if (request->get_modified_since_constraint(request) != NULL) {
		sprintf(header_if_modified_since, "If-Modified-Since: %s", request->get_modified_since_constraint(request));
		http_headers = curl_slist_append(http_headers, header_if_modified_since);
	}
	if (request->get_unmodified_since_constraint(request) != NULL) {
		sprintf(header_if_unmodified_since, "If-Unmodified-Since: %s", request->get_unmodified_since_constraint(request));
		http_headers = curl_slist_append(http_headers, header_if_unmodified_since);
	}
	request->get_range(request, &start, &length);
	if (start > 0 && length > 0) {
		sprintf(header_range, "Range: %ld-%ld", start, start + length);
		http_headers = curl_slist_append(http_headers, header_range);
	}

	http_headers = curl_slist_append(http_headers, header_host);
	http_headers = curl_slist_append(http_headers, header_date);
	http_headers = curl_slist_append(http_headers, header_auth);

	/**
	 * 发送请求
	 */
	object_group_curl_operation(OSS_HTTP_GET, resource, url, http_headers, user_data);

	/**
	 * 释放 http_headers资源
	 */
	curl_slist_free_all(http_headers);
	

	oss_map_delete(default_headers);
	if(now != NULL) {
		free(now);
		now = NULL;
	}
	if(sign != NULL) {
		free(sign);
		sign = NULL;
	}
	if(resource != NULL) {
		free(resource);
		resource = NULL;
	}
	if(url != NULL) {
		free(url);
		url = NULL;
	}
	if (user_data->header_buffer->code == 200) {
		if (retcode != NULL) *retcode = 0;
		/** 注意,output_len参数既指明了output的长度,又指明了返回文件的大小,
		 * 如果缓冲区应设置合理的大小
		 * */
		*output = user_data->recv_buffer->ptr;
		*output_len = user_data->recv_buffer->allocated;
		return construct_get_object_object_to_buffer_response_on_success(user_data);
	} else {
		if (retcode != NULL) {
			*output = NULL;
			*output_len = 0;
			*retcode = oss_get_retcode_from_response(user_data->recv_buffer->ptr);
		}
		oss_free_partial_user_data(user_data);
	}
	return NULL;
}
oss_access_control_list_t *
client_get_bucket_acl(oss_client_t *client,
                      const char *bucket_name,
                      unsigned short *retcode)
{
    assert(client != NULL);
    assert(bucket_name != NULL);

    curl_request_param_t *user_data =
        (curl_request_param_t *)malloc(sizeof(curl_request_param_t));

    user_data->send_buffer = NULL;

    user_data->recv_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
    user_data->recv_buffer->ptr = (char *)malloc(sizeof(char) * MAX_RECV_BUFFER_SIZE);
    user_data->recv_buffer->fp = NULL;
    user_data->recv_buffer->left = MAX_RECV_BUFFER_SIZE;
    user_data->recv_buffer->allocated = MAX_RECV_BUFFER_SIZE;
    memset(user_data->recv_buffer->ptr, 0, MAX_RECV_BUFFER_SIZE);

    user_data->header_buffer = (param_buffer_t *)malloc(sizeof(param_buffer_t));
    user_data->header_buffer->ptr = (char *)malloc(sizeof(char) * MAX_HEADER_BUFFER_SIZE);
    user_data->header_buffer->fp = NULL;
    user_data->header_buffer->left = MAX_HEADER_BUFFER_SIZE;
    user_data->header_buffer->allocated = MAX_HEADER_BUFFER_SIZE;
    memset(user_data->header_buffer->ptr, 0, MAX_HEADER_BUFFER_SIZE);

    unsigned int bucket_name_len = strlen(bucket_name);
    char *resource = (char *)malloc(sizeof(char) * bucket_name_len + 16);
    char *url = (char *)malloc(
                    sizeof(char) * (bucket_name_len + strlen(client->endpoint) + 8));

    char header_host[256]  = {0};
    char header_date[48]  = {0};
    char header_auth[128] = {0};
    char *now;
    unsigned int sign_len = 0;

    oss_map_t *default_headers = oss_map_new(16);

    /**
     * 构造参数,resource,url 赋值,
     * */
    sprintf(resource, "/%s?acl", bucket_name);
    sprintf(url, "%s/%s?acl", client->endpoint, bucket_name);
    sprintf(header_host,"Host: %s", client->endpoint);
    now = (char *)oss_get_gmt_time();
    sprintf(header_date, "Date: %s", now);

    /**
     * 请求头部构造
     */
    oss_map_put(default_headers, OSS_DATE, now);

    /**
     * 生成签名值
     */
    char *sign = (char *)generate_authentication(client->access_key, OSS_HTTP_GET,
                 default_headers, NULL, resource, &sign_len);

    sprintf(header_auth, "Authorization: OSS %s:%s", client->access_id, sign);

    /**
     * 自定义 HTTP 请求头部
     */
    struct curl_slist *http_headers = NULL;

    http_headers = curl_slist_append(http_headers, header_host);
    http_headers = curl_slist_append(http_headers, header_date);
    http_headers = curl_slist_append(http_headers, header_auth);

    /**
     * 发送请求
     */
    bucket_curl_operation(OSS_HTTP_GET, resource, url, http_headers, user_data);

    /**
     * 释放 http_headers资源
     */
    curl_slist_free_all(http_headers);
    oss_map_delete(default_headers);
    if(now != NULL) {
        free(now);
        now = NULL;
    }
    if(sign != NULL) {
        free(sign);
        sign = NULL;
    }
    if(resource != NULL) {
        free(resource);
        resource = NULL;
    }
    if(url != NULL) {
        free(url);
        url = NULL;
    }
    if (user_data->header_buffer->code != 200) {
        if (retcode != NULL)
            *retcode = oss_get_retcode_from_response(user_data->recv_buffer->ptr);
        oss_free_user_data(user_data);
        return NULL;
    } else {
        if (retcode != NULL) *retcode = 0;
        return construct_get_bucket_acl_response(user_data);
    }
}