コード例 #1
0
int
client_test(
    http_test_info_t *			info,
    int					timer)	
{
    int                                 rc = 0;
    globus_result_t                     result;
    int                                 header_cnt = 0;
    char                                content_length_buffer[64];
    globus_xio_http_header_t            headers[2];
    globus_xio_handle_t                 handle;
    int                                 i;
    size_t                              nbytes;
    globus_xio_data_descriptor_t        descriptor;
    int                                 status_code;
    char *                              reason_phrase;


    globus_utp_start_timer(timer);
    if (info->transfer_encoding != NULL)
    {
        headers[header_cnt].name = "Transfer-Encoding";
        headers[header_cnt].value = info->transfer_encoding;

        header_cnt++;

    }

    if ((info->version == GLOBUS_XIO_HTTP_VERSION_1_0) ||
            ((info->transfer_encoding != NULL)
                && strcmp(info->transfer_encoding, IDENTITY) == 0))
    {
        sprintf(content_length_buffer, "%lu", (unsigned long) info->size);

        headers[header_cnt].name = "Content-Length";
        headers[header_cnt].value = &content_length_buffer[0];

        header_cnt++;
    }

    handle = NULL;

    result = http_test_client_request(
	    &handle,
	    info->tcp_driver,
	    info->http_driver,
	    info->stack,
	    info->contact,
	    "%2fpost-test",
	    "POST",
	    info->version,
	    headers,
	    header_cnt);

    if (result != GLOBUS_SUCCESS)
    {
	fprintf(stderr, "Error making request: %s\n",
		globus_object_printable_to_string(
		globus_error_get(result)));
	rc = 50;
	goto error_exit;
    }

    for (i = 0; i < info->iterations; i++)
    {
	result = globus_xio_write(
		handle,
		info->buffer,
		info->size,
		info->size,
		&nbytes,
		NULL);

	if (result == GLOBUS_SUCCESS)
	{
	    if (nbytes != info->size)
	    {
		fprintf(stderr, "Didn't write all I expected.\n");
	    }
	}
	else
	{
	    fprintf(stderr, "Error writing data: %s\n",
		globus_object_printable_to_string(globus_error_peek(result)));
	}
    }
    globus_xio_handle_cntl(
	    handle,
	    info->http_driver,
	    GLOBUS_XIO_HTTP_HANDLE_SET_END_OF_ENTITY);
    /* READ RESPONSE */
    result = globus_xio_data_descriptor_init(&descriptor, handle);
    if (result != GLOBUS_SUCCESS)
    {
	rc = 51;

        goto close_exit;
    }
    result = globus_xio_read(
            handle,
            info->buffer,
            0,
            0,
            NULL,
            descriptor);
    if (result != GLOBUS_SUCCESS)
    {
        rc = 51;
        goto close_exit;
    }

    result = globus_xio_data_descriptor_cntl(
            descriptor,
            info->http_driver,
            GLOBUS_XIO_HTTP_GET_RESPONSE,
            &status_code,
            &reason_phrase,
            NULL,
            NULL);
    if (result != GLOBUS_SUCCESS || status_code < 200 || status_code > 299)
    {
        fprintf(stderr, "Get failed with \"%03d %s\"\n",
                status_code,
                reason_phrase);

        rc = 51;
        goto close_exit;
    }

    result = globus_xio_read(
            handle,
            info->buffer,
            info->size,
            1,
            &nbytes,
            NULL);
    if (result && !http_is_eof(result))
    {       
        fprintf(stderr, "Error reading eof from http: %s\n",
                globus_error_print_friendly(globus_error_get(result)));
    }

close_exit:
    globus_xio_close(handle, NULL);
    globus_utp_stop_timer(timer);

error_exit:

    return rc;
}
コード例 #2
0
int
client_test(
    http_test_info_t *			info,
    int					timer)	
{
    int                                 rc = 0;
    globus_result_t                     result;
    int                                 header_cnt = 0;
    char                                content_length_buffer[64];
    globus_xio_http_header_t            headers[2];
    globus_xio_handle_t                 handle;
    int                                 i;
    globus_xio_data_descriptor_t        descriptor;
    globus_byte_t                       buffer[1];
    int                                 status_code;
    char *                              reason_phrase;
    globus_utp_start_timer(timer);
    if (info->transfer_encoding != NULL)
    {
        headers[header_cnt].name = "Transfer-Encoding";
        headers[header_cnt].value = info->transfer_encoding;

        header_cnt++;

    }

    if ((info->version == GLOBUS_XIO_HTTP_VERSION_1_0) ||
            ((info->transfer_encoding != NULL)
                && strcmp(info->transfer_encoding, IDENTITY) == 0))
    {
        sprintf(content_length_buffer, "%lu", (unsigned long) info->size);

        headers[header_cnt].name = "Content-Length";
        headers[header_cnt].value = &content_length_buffer[0];

        header_cnt++;
    }

    handle = NULL;
    for (i = 0; i < info->iterations; i++)
    {

        if (handle != NULL)
        {
            globus_xio_close(handle, NULL);
        }
        result = http_test_client_request(
                &handle,
                info->tcp_driver,
                info->http_driver,
                info->stack,
                info->contact,
                "%2fpost-test",
                "POST",
                info->version,
                headers,
                header_cnt);

        if (result != GLOBUS_SUCCESS)
        {
            fprintf(stderr, "Error making request: %s\n",
                    globus_object_printable_to_string(
                    globus_error_get(result)));
            rc = 50;
            goto error_exit;
        }

        result = globus_l_xio_test_write_buffer(
                handle,
                info->buffer,
                info->size,
		info->http_driver);

        if (result != GLOBUS_SUCCESS)
        {
            rc = 51;
            break;
        }
        /* READ RESPONSE */
        result = globus_xio_data_descriptor_init(&descriptor, handle);
        if (result != GLOBUS_SUCCESS)
        {
            rc = 51;
            goto close_exit;
        }
        result = globus_xio_read(
                handle,
                buffer,
                0,
                0,
                NULL,
                descriptor);
        if (result != GLOBUS_SUCCESS)
        {
            rc = 51;
            goto close_exit;
        }
        result = globus_xio_data_descriptor_cntl(
                descriptor,
                info->http_driver,
                GLOBUS_XIO_HTTP_GET_RESPONSE,
                &status_code,
                &reason_phrase,
                NULL,
                NULL);
        if (result != GLOBUS_SUCCESS || status_code < 200 || status_code > 299)
        {
            fprintf(stderr, "Get failed with \"%03d %s\"\n",
                    status_code,
                    reason_phrase);
            rc = 51;
            goto close_exit;
        }

        result = globus_l_xio_test_read_buffer(
                handle,
                info->buffer,
                info->size);
        if (result != GLOBUS_SUCCESS)
        {
            rc = 52;
        }
        info->done = 0;

        if (rc != 0)
        {
            break;
        }
    }

close_exit:
    globus_xio_close(handle, NULL);
    globus_utp_stop_timer(timer);
error_exit:

    return rc;
}
コード例 #3
0
static
void
gfs_l_xio_cp_read_cb(
    globus_xio_handle_t                 handle,
    globus_result_t                     result,
    globus_byte_t *                     buffer,
    globus_size_t                       len,
    globus_size_t                       nbytes,
    globus_xio_data_descriptor_t        data_desc,
    void *                              user_arg)
{
    gfs_l_xio_read_buffer_t *           read_buf;
    gfs_i_xio_cp_handle_t *             cp_h;

    read_buf = (gfs_l_xio_read_buffer_t *) user_arg;
    cp_h = read_buf->whos_my_daddy;

    globus_mutex_lock(&cp_h->mutex);
    {
        read_buf->nbytes = nbytes;
        if(result != GLOBUS_SUCCESS)
        {
            if(eof)
            {
                read_buf->eof = GLOBUS_TRUE;
            }
            else
            {
                /* what if this is just EOF */
                goto error;
            }
        }
        /* it is possible to get here in the CLOSING state without an error */
        if(cp_h->state == GFS_CIO_CP_STATE_ERROR)
        {
            goto error;
        }

        /* XXX need to get an offset for this buffer */
        read_buf->nbytes = nbytes;
        result = globus_xio_data_descriptor_cntl(
            data_desc,
            NULL,
            GLOBUS_XIO_DD_GET_OFFSET,
            &offset);
        if(result != GLOBUS_SUCCESS)
        {
            goto error;
        }
        read_buf->offset = offset;

        if(!globus_fifo_empty(cp_h->write_q))
        {
            read_buf->write_xio = 
                (globus_xio_handle_t) globus_fifo_dequeue(cp_h->write_q);
            result = globus_xio_handle_cntl(
                read_buf->write_xio,
                GLOBUS_XIO_QUERY,
                GLOBUS_XIO_SEEK,
                read_buf->offset);
            if(result != GLOBUS_SUCCESS)
            {
                goto error;
            }

            result = globus_xio_register_write(
                read_buf->write_xio,
                read_buf->buffer,
                read_buf->nbytes,
                read_buf->nbytes,
                NULL,
                gfs_l_xio_cp_write_cb,
                read_buf);
            if(result != GLOBUS_SUCCESS)
            {
                goto error;
            }
        }
        else
        {
            /* stick this one in the queue */
            globus_fifo_enqueue(&cp_h->read_buffer_q, read_buf);
        }

        if(!eof)
        {
            /* make and post a new one */
            read_buf = (gfs_l_xio_read_buffer_t *)
                globus_calloc(sizeof(gfs_l_xio_read_buffer_t)+block_size, 1);
            read_buf->block_size = cp_h->block_size;
            read_buf->whos_my_daddy = cp_h;
            /* do this last since it can inspire the CLOSING state */
            gfs_l_xio_cp_post_read(xio_h, read_buf);
        }
        else
        {
            /* remove it from close q and close */
            globus_fifo_remove(cp_h->read_all_q, read_buf->read_xio);
            result = globus_xio_register_close(
                read_buf->read_xio,
                NULL,
                gfs_l_xio_cp_close_cb,
                cp_h);
            if(result != GLOBUS_SUCCESS)
            {
                cp_h->read_handle_count--;
            }
            if(cp_h->read_handle_count <= 0)
            {
                gfs_l_xio_close_write_handles(cp_h);
            }
        }
    }
    globus_mutex_unlock(&cp_h->mutex);

    return;

error:
    globus_free(read_buf);
    gfs_l_xio_cp_error(cp_h, result);
    globus_mutex_unlock(&cp_h->mutex);
}
コード例 #4
0
globus_result_t
globus_usage_stats_handle_init(
    globus_usage_stats_handle_t *       handle,
    uint16_t                            code,
    uint16_t                            version,
    const char *                        targets)
{
    globus_result_t                     result = GLOBUS_SUCCESS;
#ifndef TARGET_ARCH_ARM
    globus_i_usage_stats_handle_t *     new_handle;
    char *                              targets_env;
    globus_list_t *                     targets_list;
    char *                              contact;
    globus_sockaddr_t                   addr;
    int                                 host[16];
    int                                 count;
    char                                hostname[255];
    int                                 rc = 0;
    int                                 i;

    new_handle = globus_calloc(1, sizeof(globus_i_usage_stats_handle_t));
    if(!new_handle)
    {
        return globus_error_put(
            globus_error_construct_error(
                GLOBUS_USAGE_MODULE,
                NULL,
                GLOBUS_USAGE_STATS_ERROR_TYPE_OOM,
                __FILE__,
                _globus_func_name,
                __LINE__,
                "Out of memory"));
    }

    new_handle->optout = getenv("GLOBUS_USAGE_OPTOUT");
    if(new_handle->optout)
    {
        *handle = new_handle;
        return GLOBUS_SUCCESS;
    }

    globus_mutex_init(&new_handle->mutex, NULL);

    new_handle->inuse = GLOBUS_FALSE;
    
    new_handle->code = htons(code);
    new_handle->version = htons(version);

    memset(new_handle->data, 0, PACKET_SIZE);

    memcpy(new_handle->data + new_handle->data_length, 
           (void *)&new_handle->code, 2);
    new_handle->data_length += 2;

    memcpy(new_handle->data + new_handle->data_length, 
           (void *)&new_handle->version, 2);
    new_handle->data_length += 2;

    rc = globus_libc_gethostaddr(&addr);
    if(rc != 0)
    {
        return globus_error_put(
            globus_error_construct_error(
                GLOBUS_USAGE_MODULE,
                NULL,
                GLOBUS_USAGE_STATS_ERROR_TYPE_UNKNOWN_HOSTNAME,
                __FILE__,
                _globus_func_name,
                __LINE__,
                "Unable to get hostaddr."));
    }
    
    result = globus_libc_addr_to_contact_string(
        &addr, GLOBUS_LIBC_ADDR_NUMERIC, &contact);
    if(result != GLOBUS_SUCCESS)
    {
        return result;
    }

    result = globus_libc_contact_string_to_ints(
        contact, host, &count, NULL);
    if(result != GLOBUS_SUCCESS)
    {
        return result;
    }

    globus_libc_free(contact);

    if(count == 4)
    {
        memset(new_handle->data + new_handle->data_length, 0, 12);
        new_handle->data_length += 12;
    }

    for (i = 0; i < count; i++)
    {
        new_handle->data[new_handle->data_length++] = (unsigned char) host[i];
    }

    /* timestamp will go here */
    new_handle->data_length += 4;

    if(globus_libc_gethostname(hostname, 255) == 0)
    {
        new_handle->data_length += 
            sprintf((char *) new_handle->data + new_handle->data_length,
                "HOSTNAME=%s", hostname);
    }
    new_handle->header_length = new_handle->data_length;
    
    if(targets)
    {
        globus_l_usage_stats_split_targets(targets, &new_handle->targets);
    }
    else if((targets_env = getenv("GLOBUS_USAGE_TARGETS")) 
            != NULL)
    {
        globus_l_usage_stats_split_targets(
            targets_env, &new_handle->targets);
    }
    else
    {
        globus_l_usage_stats_split_targets(
            GLOBUS_L_USAGE_STATS_DEFAULT_TARGETS, 
            &new_handle->targets);
    }


    result = globus_xio_handle_create(
        &new_handle->xio_handle,
        globus_l_usage_stats_stack);
    if(result != GLOBUS_SUCCESS)
    {
        return result;
    }

    result = globus_xio_open(
        new_handle->xio_handle,
        NULL, NULL);
    if(result != GLOBUS_SUCCESS)
    {
        return result;
    }

    targets_list = new_handle->targets;
    while(targets_list)
    {
        globus_xio_data_descriptor_t *  dd;
        dd = (globus_xio_data_descriptor_t *) globus_malloc(
            sizeof(globus_xio_data_descriptor_t));
            
        result = globus_xio_data_descriptor_init(
            dd,
            new_handle->xio_handle);
        if(result != GLOBUS_SUCCESS)
        {
            return result;
        }

        result = globus_xio_data_descriptor_cntl(
            *dd,
            globus_l_usage_stats_udp_driver,
            GLOBUS_XIO_UDP_SET_CONTACT,
            (char *)globus_list_first(targets_list));
        if(result != GLOBUS_SUCCESS)
        {
            goto exit;
        }
        
        globus_list_insert(&new_handle->xio_desc_list, dd);
        
        targets_list = globus_list_rest(targets_list);
    }
    
    *handle = new_handle;

    return GLOBUS_SUCCESS;

exit:
#endif
    return result;
}
コード例 #5
0
int
client_main(
    const char *                        filename,
    const char *                        contact,
    globus_xio_http_version_t           http_version)
{
    int                                 rc;
    globus_result_t                     result;
    int                                 header_cnt = 0;
    char                                content_length_buffer[64];
    globus_xio_http_header_t            headers[2];
    globus_xio_handle_t                 handle;
    int                                 i;
    globus_xio_data_descriptor_t        descriptor;
    globus_byte_t                       buffer[1];
    int                                 status_code;
    char *                              reason_phrase;

    rc = globus_l_xio_test_read_file(filename);
    if (rc != 0)
    {
        goto error_exit;
    }

    if (transfer_encoding != NULL)
    {
        headers[header_cnt].name = "Transfer-Encoding";
        headers[header_cnt].value = transfer_encoding;

        header_cnt++;

    }

    if ((http_version == GLOBUS_XIO_HTTP_VERSION_1_0) ||
            ((transfer_encoding != NULL)
                && strcmp(transfer_encoding, IDENTITY) == 0))
    {
        sprintf(content_length_buffer, "%ld", file_size);

        headers[header_cnt].name = "Content-Length";
        headers[header_cnt].value = &content_length_buffer[0];

        header_cnt++;
    }

    handle = NULL;
    for (i = 0; i < iterations; i++)
    {

        if (handle != NULL)
        {
            globus_xio_close(handle, NULL);
        }
        result = http_test_client_request(
                &handle,
                tcp_driver,
                http_driver,
                stack,
                contact,
                "%2fpost-test",
                "POST",
                http_version,
                headers,
                header_cnt);

        if (result != GLOBUS_SUCCESS)
        {
            fprintf(stderr, "Error making request: %s\n",
                    globus_object_printable_to_string(
                    globus_error_get(result)));
            rc = 50;
            goto error_exit;
        }

        result = globus_l_xio_test_write_buffer(
                handle,
                message_body,
                file_size,
                buffer_size);

        if (result != GLOBUS_SUCCESS)
        {
            rc = 51;
            break;
        }

        /* READ RESPONSE */
        result = globus_xio_data_descriptor_init(&descriptor, handle);
        if (result != GLOBUS_SUCCESS)
        {
            rc = 51;
            goto close_exit;
        }
        result = globus_xio_read(
                handle,
                buffer,
                0,
                0,
                NULL,
                descriptor);
        if (result != GLOBUS_SUCCESS)
        {
            rc = 51;
            goto close_exit;
        }
        result = globus_xio_data_descriptor_cntl(
                descriptor,
                http_driver,
                GLOBUS_XIO_HTTP_GET_RESPONSE,
                &status_code,
                &reason_phrase,
                NULL,
                NULL);
        if (result != GLOBUS_SUCCESS || status_code < 200 || status_code > 299)
        {
            fprintf(stderr, "Get failed with \"%03d %s\"\n",
                    status_code,
                    reason_phrase);
            rc = 51;
            goto close_exit;
        }

        result = globus_l_xio_test_read_buffer(
                handle,
                message_body,
                file_size,
                buffer_size);

        if (result != GLOBUS_SUCCESS)
        {
            rc = 52;
        }

        if (rc != 0)
        {
            break;
        }
    }

close_exit:
    globus_xio_close(handle, NULL);
error_exit:
    if (rc == 0)
    {
        printf("Success\n");
    }
    else
    {
        printf("Error\n");
    }

    return rc;
}
コード例 #6
0
ファイル: test-dsi.c プロジェクト: ellert/globus-dsi-rest
static
void *
globus_l_dsi_rest_thread(
    void                               *arg)
{
    globus_l_dsi_rest_handle_t         *dsi_rest_handle = arg;
    globus_xio_data_descriptor_t        descriptor;
    size_t                              buf_size = 256;
    unsigned char                      *buf = malloc(buf_size);
    globus_size_t                       nbytes;
    char                               *encoded_uri;

    globus_mutex_lock(&dsi_rest_handle->mutex);
    while (!dsi_rest_handle->terminate)
    {
        char                       *method;
        char                       *uri;
        globus_xio_http_version_t   http_version;
        globus_hashtable_t          headers;
        globus_result_t             result;

        globus_mutex_unlock(&dsi_rest_handle->mutex);
        result = globus_xio_server_accept(
                &dsi_rest_handle->xio_handle,
                dsi_rest_handle->xio_server);
        globus_mutex_lock(&dsi_rest_handle->mutex);

        if (result != GLOBUS_SUCCESS)
        {
            continue;
        }
        result = globus_xio_open(
                dsi_rest_handle->xio_handle,
                NULL,
                NULL);
        if (result != GLOBUS_SUCCESS)
        {
            goto end_this_socket;
        }

        result = globus_xio_data_descriptor_init(&descriptor, dsi_rest_handle->xio_handle);
        if (result != GLOBUS_SUCCESS)
        {
            goto end_this_socket;
        }

        result = globus_xio_read(
                dsi_rest_handle->xio_handle,
                buf,
                0,
                0,
                &nbytes,
                descriptor);

        if (result != GLOBUS_SUCCESS)
        {
            goto end_this_socket;
        }

        result = globus_xio_data_descriptor_cntl(
                descriptor,
                dsi_rest_handle->http_driver,
                GLOBUS_XIO_HTTP_GET_REQUEST,
                &method,
                &uri,
                &http_version,
                &headers);

        globus_dsi_rest_uri_escape(uri, &encoded_uri);

        char *uripath = globus_common_create_string("%s/%s", dsi_rest_handle->root, encoded_uri);
        if (strcmp(method, "GET") == 0)
        {
            int fd;
            fd = open(uripath, O_RDONLY);
            if (fd < 0)
            {
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                        "Connection",
                        "Close");
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                        "Content-Length",
                        "0");
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_STATUS_CODE,
                        404);
            }
            else
            {
                globus_size_t read_amt = 0;
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                        "Connection",
                        "Close");
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_STATUS_CODE,
                        200);

                do
                {
                    read_amt = read(fd, buf, buf_size);
                    if (read_amt > 0)
                    {
                        globus_size_t written_amt = 0;

                        while (written_amt < read_amt)
                        {
                            globus_size_t this_write;

                            result = globus_xio_write(
                                dsi_rest_handle->xio_handle,
                                buf+written_amt,
                                read_amt-written_amt,
                                read_amt-written_amt,
                                &this_write,
                                NULL);
                            if (this_write > 0)
                            {
                                written_amt += this_write;
                            }
                            else if (result != GLOBUS_SUCCESS)
                            {
                                break;
                            }
                        }
                    }
                }
                while (read_amt > 0);
                close(fd);
            }
        }
        else
        {
            int fd = open(uripath, O_WRONLY|O_CREAT, 0700);

            if (fd < 0)
            {
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_STATUS_CODE,
                        500);
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                        "Content-Length",
                        "0");
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                        "Connection",
                        "Close");
            }
            else
            {
                off_t total_written=0;

                if (nbytes > 0)
                {
                    globus_size_t written_amt = 0;

                    while (written_amt < nbytes)
                    {
                        globus_size_t this_write;

                        this_write = write(fd, buf+written_amt, nbytes-written_amt);
                        if (this_write > 0)
                        {
                            written_amt += this_write;
                            total_written += this_write;
                        }
                    }
                }
                do
                {

                    result = globus_xio_read(
                        dsi_rest_handle->xio_handle,
                        buf,
                        buf_size,
                        1,
                        &nbytes,
                        NULL);
                    if (nbytes > 0)
                    {
                        globus_size_t written_amt = 0;

                        while (written_amt < nbytes)
                        {
                            globus_size_t this_write;

                            this_write = write(fd, buf+written_amt, nbytes-written_amt);
                            if (this_write > 0)
                            {
                                written_amt += this_write;
                                total_written += this_write;
                            }
                        }
                    }
                    if (result != GLOBUS_SUCCESS)
                    {
                        if (globus_error_match(
                                globus_error_peek(result),
                                GLOBUS_XIO_MODULE,
                                GLOBUS_XIO_ERROR_EOF)
                            || globus_xio_driver_error_match(
                                    dsi_rest_handle->http_driver,
                                    globus_error_peek(result),
                                    GLOBUS_XIO_HTTP_ERROR_EOF))
                        {
                            result = GLOBUS_SUCCESS;
                            break;
                        }
                        else
                        {
                            globus_xio_handle_cntl(
                                    dsi_rest_handle->xio_handle,
                                    dsi_rest_handle->http_driver,
                                    GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_STATUS_CODE,
                                    500);
                            globus_xio_handle_cntl(
                                    dsi_rest_handle->xio_handle,
                                    dsi_rest_handle->http_driver,
                                    GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                                    "Content-Length",
                                    "0");
                            globus_xio_handle_cntl(
                                    dsi_rest_handle->xio_handle,
                                    dsi_rest_handle->http_driver,
                                    GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                                    "Connection",
                                    "Close");
                            goto xio_error;
                        }
                    }
                }
                while (nbytes > 0);
                close(fd);
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_STATUS_CODE,
                        204);
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                        "Content-Length",
                        "0");
                globus_xio_handle_cntl(
                        dsi_rest_handle->xio_handle,
                        dsi_rest_handle->http_driver,
                        GLOBUS_XIO_HTTP_HANDLE_SET_RESPONSE_HEADER,
                        "Connection",
                        "Close");
            }
        }
xio_error:
        free(uripath);
        result = globus_xio_handle_cntl(
                dsi_rest_handle->xio_handle,
                dsi_rest_handle->http_driver,
                GLOBUS_XIO_HTTP_HANDLE_SET_END_OF_ENTITY);
end_this_socket:
        result = globus_xio_close(
                dsi_rest_handle->xio_handle,
                NULL);
        dsi_rest_handle->xio_handle = NULL;
    }
    dsi_rest_handle->terminate_complete = true;
    globus_cond_signal(&dsi_rest_handle->cond);
    globus_mutex_unlock(&dsi_rest_handle->mutex);

    return NULL;
}