コード例 #1
0
ファイル: main_config.c プロジェクト: amogrid/redcurrant
static GByteArray*
_download_to_gba(ne_session *session, const gchar *path_url, GError **error)
{
	GByteArray *gba;
	ne_request *http_request;

	DEBUG("About to download [%s] into a memory buffer", path_url);

	gba = g_byte_array_new();
	http_request = _build_request(session, path_url);
	ne_add_response_body_reader(http_request, ne_accept_2xx, read_to_gba, gba);

	switch (ne_request_dispatch(http_request)) {
	case NE_OK:
		if (ne_get_status(http_request)->klass != 2) {
			GSETERROR (error, "Failed to download '%s': %s", path_url, ne_get_error(session));
			g_byte_array_free(gba, TRUE);
			gba = NULL;
		}
		break;
	case NE_AUTH:
	case NE_CONNECT:
	case NE_TIMEOUT:
	case NE_ERROR:
	default:
		GSETERROR(error,"Failed download '%s': %s", path_url, ne_get_error(session));
		g_byte_array_free(gba, TRUE);
		gba = NULL;
		break;
	}

	ne_request_destroy(http_request);
	return gba;
}
コード例 #2
0
ファイル: common.c プロジェクト: tolsen/Prestan
void
my_mkcol2_proppatch(char* uri, int depth, const ne_propname pops[])
{
	char tmp[256] = "/tmp/Davtest-XXXXXX";
	char myuri[128];
	int i, fd;

	if ( (fd=mkstemp(tmp)) < 0){
		perror("mkstemp() :");
		return ;
	}

	for( i=0; i<4; i++)
		write(fd, tmp, sizeof(tmp));

	if ( depth > 1){
		memset(myuri, 0, sizeof(myuri));
		strcpy( myuri, uri);
		sprintf( myuri, "%ssub/", myuri);
    		ONV(ne_mkcol(i_session, myuri), 
			("MKCOL %s: %s", myuri, ne_get_error(i_session)));
		ONMREQ("PROPPATCH",myuri, ne_proppatch(i_session, myuri, pops));
		my_mkcol2( myuri, depth-1);
	}else if ( depth == 1)
		for ( i=0; i<pget_option.width; i++){
			memset(myuri, 0, sizeof(myuri));
			strcpy( myuri, uri);
			sprintf( myuri, "%sfile%d", myuri, i);
    			ONV(ne_put(i_session, myuri, fd),
				("PUT of %s: %s", myuri, ne_get_error(i_session)));
		}

	return;
}
コード例 #3
0
ファイル: copymove.c プロジェクト: Akron/mojo-plugin-webdav
static int copy_overwrite(void)
{
    PRECOND(copy_ok);

    /* Do it again with Overwrite: F to check that fails. */
    ONN("COPY on existing resource with Overwrite: F should fail (RFC2518:S8.8.4)",
	ne_copy(i_session, 0, NE_DEPTH_INFINITE, src, dest) != NE_ERROR);

    if (STATUS(412)) {
	t_warning("COPY-on-existing fails with 412");
    }
    
    ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, dest),
	("COPY-on-existing with 'Overwrite: T' should succeed (RFC2518:S8.8.4): %s", ne_get_error(i_session)));

    /* tricky one this, I didn't think it should work, but the spec
     * makes it look like it should. */
    ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, coll),
	("COPY overwrites collection: %s", ne_get_error(i_session)));
    
    if (STATUS(204)) {
	t_warning("COPY to existing resource didn't give 204 (RFC2518:S8.8.5)");
    }

    return OK;
}
コード例 #4
0
ファイル: putfile.c プロジェクト: elambert/honeycomb
static void
connect_server()
{
    ne_session *sess;
    ne_server_capabilities caps;
    int ret;

    /* set up the connection */

    ne_sock_init();

    memset(&session, 0, sizeof session);
    session.uri.scheme = ne_strdup("http");
    session.uri.host = hc_host;
    session.uri.port = port; 
    session.uri.path = ne_strdup("/webdav/"); /* always '/'-terminate */

    session.sess = sess = ne_session_create(session.uri.scheme, 
                                     session.uri.host, 
                                     session.uri.port);

    /* make the connection */

    ne_set_useragent(sess, "hctest/");  /* needed? */
/*
not needed to connect
    ne_lockstore_register(session.locks, sess);
    ne_redirect_register(sess);
*/
    /* convenient status */
    ne_set_status(sess, connection_status, NULL);
    ne_set_progress(sess, transfer_progress, NULL);

    /* execute connect */
    ret = ne_options(sess, session.uri.path, &caps);
    
    switch (ret) {
    case NE_OK:
	session.connected = true;
/*
	if (set_path(session.uri.path)) {
	    close_connection();
	}
*/
	break;
    case NE_CONNECT:
        printf("got NE_CONNECT\n");
        quit(1);
	break;
    case NE_LOOKUP:
	puts(ne_get_error(sess));
        quit(1);
	break;
    default:
	printf("Could not open collection (default connect err):\n%s\n",
	       ne_get_error(sess));
        quit(1);
	break;
    }
}
コード例 #5
0
ファイル: of_mkdirs.c プロジェクト: elambert/honeycomb
static void
mk_dir(char **md_vals, int depth)
{
    /*
     *  construct path to check
     */
    int ret;
    char remote_path[1024];
    switch (depth) {
      case 1:
        sprintf(remote_path, "%s/%s", "/webdav/oFotoHashDirs", md_vals[0]);
        break;
      case 2:
        sprintf(remote_path, "%s/%s/%s", "/webdav/oFotoHashDirs",
                        md_vals[0], md_vals[1]);
        break;
      case 3:
        sprintf(remote_path, "%s/%s/%s/%s", "/webdav/oFotoHashDirs",
                        md_vals[0], md_vals[1], md_vals[2]);
        break;
      case 4:
        sprintf(remote_path, "%s/%s/%s/%s/%s", "/webdav/oFotoHashDirs",
                        md_vals[0], md_vals[1], md_vals[2],
                        md_vals[3]);
        break;
      case 5:
        sprintf(remote_path, "%s/%s/%s/%s/%s/%s", "/webdav/oFotoHashDirs",
                        md_vals[0], md_vals[1], md_vals[2],
                        md_vals[3], md_vals[4]);
        break;
      case 6:
        sprintf(remote_path, "%s/%s/%s/%s/%s/%s/%s", "/webdav/oFotoHashDirs",
                        md_vals[0], md_vals[1], md_vals[2],
                        md_vals[3], md_vals[4], md_vals[5]);
        break;
    }
    if (hc_host == NULL) {
        printf("%s\n", remote_path);
        return;
    }
    if (verbose)
        printf("%s\n", remote_path);

    ret = ne_mkcol(session.sess, remote_path);
    if (ret != NE_OK) {
        if (strstr(ne_get_error(session.sess), "409 Conflict")) {
            if (verbose)
                printf("  already exists\n");
            else
                printf("already exists: %s\n", remote_path);
            return;
        }
        printf("failed:  %s\n", ne_get_error(session.sess));
        quit(1);
    }
    count++;
}
コード例 #6
0
ファイル: locks.c プロジェクト: tolsen/limeberry
static int lock_collection(void)
{
    struct ne_lock dummy;
    char *tmp,*tmp2;
    
    CALL(getlock(ne_lockscope_exclusive, NE_DEPTH_INFINITE));
    
    PRECOND(gotlock);

    memcpy(&dummy, &reslock, sizeof(reslock));
    dummy.token = NULL;
    dummy.uri.path = collZ;
    dummy.owner = ne_strdup("litmus: owner lock");
    dummy.depth = NE_DEPTH_INFINITE;
    dummy.type = ne_locktype_write;
    dummy.scope = ne_lockscope_exclusive;
    
    ONNREQ2("LOCK on second collection for further tests", 
	    ne_lock(i_session, &dummy));
    gotlock = ne_lock_copy(&dummy);
    ne_lockstore_add(store, gotlock);

    /* Testing creation of directories under a collection */ 
    ONV(ne_mkcol(i_session, collX),
        ("MKCOL %s: %s", collX, ne_get_error(i_session)));
    ONV(ne_mkcol(i_session, collY),
        ("MKCOL %s: %s", collY, ne_get_error(i_session)));

    upload_foo("lockcoll/collX/temp");
    tmp = ne_concat(collY,"copy-temp",NULL);	
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp),
	("collection COPY `%s' to `%s': %s", res2, tmp,
	 ne_get_error(i_session)));
    free(tmp);
    
    tmp2=ne_concat(collZ,"testing",NULL);
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp2),
	("collection COPY `%s' to `%s': %s", res2, tmp2,
	 ne_get_error(i_session)));

    ne_free(res3);	
    res3 = ne_concat(i_path,"not-existing",NULL);

 
    /* change res to point to a normal resource for subsequent
     * {not_,}owner_modify tests */
    res = ne_concat(coll, "lockme.txt", NULL);
    return upload_foo("lockcoll/lockme.txt");
}
コード例 #7
0
ファイル: locks.c プロジェクト: tolsen/limeberry
static int owner_modify(void)
{
    char *tmp;
    ne_propname pname = { "http://webdav.org/neon/litmus/", "random" };
    ne_proppatch_operation pops[] = { 
	{ NULL, ne_propset, "foobar" },
	{ NULL }
    };
    PRECOND(gotlock);

    ONV(ne_put(i_session, res, i_foo_fd),
	("PUT on locked resource failed: %s", ne_get_error(i_session)));
    
    tmp = ne_concat(i_path, "whocares", NULL);
    ONN("COPY of locked resource", 
	ne_copy(i_session, 1, NE_DEPTH_ZERO, res, tmp) == NE_ERROR);
    
   if (STATUS(201))
	t_warning("COPY failed with %d not 201", GETSTATUS);
    
    ONN("DELETE of locked resource by owner", 
	ne_delete(i_session, tmp) == NE_ERROR);

    if (STATUS(204)) 
	t_warning("DELETE of %s failed with %d not 200", tmp, GETSTATUS);
    free(tmp);
    
    ONN("PROPPATCH of locked resource",
	ne_proppatch(i_session, res, pops) == NE_ERROR);
    
    if (STATUS(207))
	t_warning("PROPPATCH failed with %d", GETSTATUS);

    return OK;
}
コード例 #8
0
ファイル: putfile.c プロジェクト: elambert/honeycomb
static void 
out_result(int ret)
{
    switch (ret) {
    case NE_OK:
	printf("succeeded.\n");
	break;
    case NE_AUTH:
    case NE_PROXYAUTH:
	printf("authentication failed.\n");
	break;
    case NE_CONNECT:
	printf("could not connect to server.\n");
	break;
    case NE_TIMEOUT:
	printf("connection timed out.\n");
	break;
    default:
        if (ret == NE_REDIRECT) {
            const ne_uri *dest = ne_redirect_location(session.sess);
            if (dest) {
                char *uri = ne_uri_unparse(dest);
                printf("redirect to %s\n", uri);
                ne_free(uri);
                break;
            }
        }
	printf("failed:  %s\n", ne_get_error(session.sess));
	break;
    }
}
コード例 #9
0
ファイル: netxml-ups.c プロジェクト: balooloo/nut
static int netxml_get_page(const char *page)
{
	int		ret = NE_ERROR;
	ne_request	*request;
	ne_xml_parser	*parser;

	upsdebugx(2, "%s: %s", __func__, (page != NULL)?page:"(null)");

	if (page != NULL) {
		request = ne_request_create(session, "GET", page);

		parser = ne_xml_create();

		ne_xml_push_handler(parser, subdriver->startelm_cb, subdriver->cdata_cb, subdriver->endelm_cb, NULL);

		ret = netxml_dispatch_request(request, parser);

		if (ret) {
			upsdebugx(2, "%s: %s", __func__, ne_get_error(session));
		}

		ne_xml_destroy(parser);
		ne_request_destroy(request);
	}
	return ret;
}
コード例 #10
0
ファイル: netxml-ups.c プロジェクト: balooloo/nut
void upsdrv_initinfo(void)
{
	char	*page, *last = NULL;
	char	buf[SMALLBUF];
	
	snprintf(buf, sizeof(buf), "%s", subdriver->initinfo);

	for (page = strtok_r(buf, " ", &last); page != NULL; page = strtok_r(NULL, " ", &last)) {

		if (netxml_get_page(page) != NE_OK) {
			continue;
		}

		dstate_setinfo("driver.version.data", "%s", subdriver->version);

		if (testvar("subscribe") && (netxml_alarm_subscribe(subdriver->subscribe) == NE_OK)) {
			extrafd = ne_sock_fd(sock);
			time(&lastheard);
		}

		/* Register r/w variables */
		vname_register_rw();

		/* Set UPS driver handler callbacks */
		upsh.setvar  = &setvar;
		upsh.instcmd = &instcmd;

		return;
	}

	fatalx(EXIT_FAILURE, "%s: communication failure [%s]", __func__, ne_get_error(session));
}
コード例 #11
0
ファイル: rawx.c プロジェクト: korween/oio-sds
char*
create_rawx_request_common(ne_request **req, ne_request_param_t *param, GError **err)
{
	ne_request *request = NULL;
	char str_req_id[LIMIT_LENGTH_REQID];

	if (NULL == param->session || NULL == param->method || NULL == param->cPath) {
		GSETERROR(err, "Invalid parameter");
		*req = NULL;
		return NULL;
	}

	if (NULL == (request = ne_request_create (param->session, param->method, param->cPath))) {
		GSETERROR(err, "cannot create a new WebDAV request (%s)", ne_get_error(param->session));
		*req = NULL;
		return NULL;
	}

	/* add additionnal headers */
	ne_add_request_header  (request, RAWX_HEADER_PREFIX "container-id", param->containerid);
	ne_add_request_header  (request, RAWX_HEADER_PREFIX "content-path", param->contentpath);
	ne_print_request_header(request, RAWX_HEADER_PREFIX "content-size", "%"G_GINT64_FORMAT, param->contentsize);
	ne_print_request_header(request, RAWX_HEADER_PREFIX "content-chunksnb", "%u", param->chunknb);
	ne_print_request_header(request, RAWX_HEADER_PREFIX "chunk-pos",    "%u", param->chunkpos);
	ne_print_request_header(request, RAWX_HEADER_PREFIX "chunk-size",   "%"G_GINT64_FORMAT, param->chunksize);

	/* Add request header */
	add_req_id_header(request, str_req_id, sizeof(str_req_id)-1);

	*req = request;
	return g_strdup(str_req_id);
}
コード例 #12
0
ファイル: httpbf.c プロジェクト: VineyardVolunteer/client
static Hbf_State _hbf_transfer_no_chunk(ne_session *session, hbf_transfer_t *transfer, const char *verb) {
    int res;
    const ne_status* req_status;

    ne_request *req = ne_request_create(session, verb ? verb : "PUT", transfer->url);
    if (!req)
        return HBF_MEMORY_FAIL;

    ne_add_request_header( req, "Content-Type", "application/octet-stream");

    ne_set_request_body_fd(req, transfer->fd, 0, transfer->stat_size);
    DEBUG_HBF("HBF: chunking not supported for %s", transfer->url);
    res = ne_request_dispatch(req);
    req_status = ne_get_status( req );

    if (res == NE_OK && req_status->klass == 2) {
        ne_request_destroy(req);
        return HBF_SUCCESS;
    }

    if( transfer->error_string ) free( transfer->error_string );
    transfer->error_string = strdup( ne_get_error(session) );
    transfer->status_code = req_status->code;
    ne_request_destroy(req);
    return HBF_FAIL;
}
コード例 #13
0
ファイル: cadaver.c プロジェクト: grimneko/cadaver
/* Sets the current collection to the given path.  Returns zero on
 * success, non-zero if newpath is an untolerated non-WebDAV
 * collection. */
int set_path(const char *newpath)
{
    int is_coll = (getrestype(newpath) == resr_collection);
    if (is_coll || tolerant) {
	if (!is_coll) {
	    session.isdav = 0;
	    printf(_("Ignored error: %s not WebDAV-enabled:\n%s\n"), newpath,
		   ne_get_error(session.sess));
	} else {
	    session.isdav = 1;
	}
	return 0;
    } else {
	printf(_("Could not access %s (not WebDAV-enabled?):\n%s\n"), newpath,
	       ne_get_error(session.sess));
	return 1;
    }
}
コード例 #14
0
ファイル: rawx.c プロジェクト: amogrid/redcurrant
static gboolean _ne_request(const char *host, int port, const char *target,
		const char *method, GSList *headers, GError **err)
{
	GRID_TRACE("%s", __FUNCTION__);
	gboolean result = FALSE;
	ne_session* session = ne_session_create("http", host, port);
	ne_set_connect_timeout(session, 10);
	ne_set_read_timeout(session, 30);

	GRID_DEBUG("%s http://%s:%d%s", method, host, port, target);
	ne_request* req = ne_request_create(session, method, target);
	if (NULL != req) {
		for (GSList *l = headers; l; l = l->next) {
			gchar **toks = g_strsplit(l->data, ":", 2);
			ne_add_request_header(req, toks[0], toks[1]);
			g_strfreev(toks);
		}
		switch (ne_request_dispatch(req)) {
			case NE_OK:
				if (ne_get_status(req)->klass != 2) {
					*err = NEWERROR(0, "cannot %s '%s' (%s)", method, target,
							ne_get_error(session));
				} else {
					result = TRUE;
				}
				break;
			case NE_AUTH:
			case NE_CONNECT:
			case NE_TIMEOUT:
			case NE_ERROR:
			default:
				*err = NEWERROR(0,
						"unexpected error from the WebDAV server (%s)",
						ne_get_error(session));
				break;
		}
		ne_request_destroy(req);
	} else {
		// This should be an assertion
		*err = NEWERROR(0, "Failed to create request");
	}
	ne_session_destroy (session);
	return result;
}
コード例 #15
0
ファイル: httpbf.c プロジェクト: VineyardVolunteer/client
/* Get the HTTP error code for the last request  */
static int _hbf_http_error_code(ne_session *session) {
    const char *msg = ne_get_error( session );
    char *msg2;
    int err;
    err = strtol(msg, &msg2, 10);
    if (msg == msg2) {
        err = 0;
    }
    return err;
}
コード例 #16
0
ファイル: utils.c プロジェクト: Distrotech/neon
int any_2xx_request(ne_session *sess, const char *uri)
{
    ne_request *req = ne_request_create(sess, "GET", uri);
    int ret = ne_request_dispatch(req);
    int klass = ne_get_status(req)->klass;
    ne_request_destroy(req);
    ONV(ret != NE_OK || klass != 2,
	("request failed: %s", ne_get_error(sess)));
    return ret;
}
コード例 #17
0
ファイル: common.c プロジェクト: tolsen/Prestan
int upload_foo(const char *path)
{
    char *uri = ne_concat(i_path, path, NULL);
    int ret;
    /* i_foo_fd is rewound automagically by ne_request.c */
    ret = ne_put(i_session, uri, i_foo_fd);
    free(uri);
    if (ret)
	t_context("PUT of `%s': %s", uri, ne_get_error(i_session));
    return ret;
}
コード例 #18
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
static int prep_collection(void)
{
    if (gotlock) {
        ne_lock_destroy(gotlock);
        gotlock = NULL;
    }
    ne_free(res);
    res = coll = ne_concat(i_path, "lockcoll/", NULL);
    ONV(ne_mkcol(i_session, res),
        ("MKCOL %s: %s", res, ne_get_error(i_session)));
    return OK;
}
コード例 #19
0
int http_result_code_from_session() {
    const char *p = ne_get_error( dav_session.ctx );
    char *q;
    int err;

    set_error_message(p); /* remember the error message */

    err = strtol(p, &q, 10);
    if (p == q) {
        err = ERRNO_ERROR_STRING;
    }
    return err;
}
コード例 #20
0
ファイル: locks.c プロジェクト: tolsen/limeberry
static int prep_collection(void)
{
    if (gotlock) {
        ne_lock_destroy(gotlock);
        gotlock = NULL;
    }
    ne_free(res);
    ne_free(res3);
    res = coll = ne_concat(i_path, "lockcoll/", NULL);
   
    /* Setting directories for further tests */
    collX = ne_concat(coll,"collX/",NULL);
    collY = ne_concat(coll,"collY/",NULL);
    res3 = ne_concat(collX,"temp",NULL);
    collZ = ne_concat(i_path, "lockcoll2/", NULL);
 
    ONV(ne_mkcol(i_session, res),
        ("MKCOL %s: %s", res, ne_get_error(i_session)));
    ONV(ne_mkcol(i_session, collZ),
        ("MKCOL %s: %s", collZ, ne_get_error(i_session)));

    return OK;
}
コード例 #21
0
ファイル: utils.c プロジェクト: Distrotech/neon
int any_2xx_request_body(ne_session *sess, const char *uri)
{
    ne_request *req = ne_request_create(sess, "GET", uri);
#define BSIZE 5000
    char *body = memset(ne_malloc(BSIZE), 'A', BSIZE);
    int ret;
    ne_set_request_body_buffer(req, body, BSIZE);
    ret = ne_request_dispatch(req);
    ne_free(body);
    ONV(ret != NE_OK || ne_get_status(req)->klass != 2,
	("request failed: %s", ne_get_error(sess)));
    ne_request_destroy(req);
    return ret;
}
コード例 #22
0
ファイル: loc_context.c プロジェクト: korween/oio-sds
static char *
_check_chunk(const char *cid)
{
	ne_session *session=NULL;
	ne_request *request=NULL;

	GString *str = g_string_new("");

	char **split = g_strsplit(cid, "/", 0);
	char **addr_tok = g_strsplit(split[2], ":", 2);

	if(NULL != (session = ne_session_create("http", addr_tok[0], atoi(addr_tok[1])))) {
		ne_set_connect_timeout(session, 10);
		ne_set_read_timeout(session, 30);
		/* FIXME: I'm a little harder with strrchr success presumption */
		if(NULL != (request = ne_request_create (session, "HEAD", strrchr(cid, '/')))) {
			switch (ne_request_dispatch (request)) {
				case NE_OK:
					if (ne_get_status(request)->klass != 2) {
						g_string_append_printf(str, "(Chunk unavailable : %s)",
								ne_get_error(session));
					}
					break;
				default:
					g_string_append_printf(str, "(Chunk unavailable : %s)",
							ne_get_error(session));
			}
			ne_request_destroy (request);
		} 
		ne_session_destroy (session);
	}

	g_strfreev(addr_tok);
	g_strfreev(split);

	return g_string_free(str, FALSE);
}
static GstFlowReturn
gst_neonhttp_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
{
  GstNeonhttpSrc *src;
  GstBaseSrc *basesrc;
  GstFlowReturn ret;
  gint read;

  src = GST_NEONHTTP_SRC (psrc);
  basesrc = GST_BASE_SRC_CAST (psrc);

  /* The caller should know the number of bytes and not read beyond EOS. */
  if (G_UNLIKELY (src->eos))
    goto eos;

  /* Create the buffer. */
  ret = gst_pad_alloc_buffer (GST_BASE_SRC_PAD (basesrc),
      basesrc->segment.last_stop, basesrc->blocksize,
      src->icy_caps ? src->icy_caps :
      GST_PAD_CAPS (GST_BASE_SRC_PAD (basesrc)), outbuf);

  if (G_UNLIKELY (ret != GST_FLOW_OK))
    goto done;

  read = gst_neonhttp_src_request_dispatch (src, *outbuf);
  if (G_UNLIKELY (read < 0))
    goto read_error;

  GST_LOG_OBJECT (src, "returning %u bytes", GST_BUFFER_SIZE (*outbuf));

done:
  return ret;

  /* ERRORS */
eos:
  {
    GST_DEBUG_OBJECT (src, "EOS reached");
    return GST_FLOW_UNEXPECTED;
  }
read_error:
  {
    GST_ELEMENT_ERROR (src, RESOURCE, READ,
        (NULL), ("Could not read any bytes (%i, %s)", read,
            ne_get_error (src->session)));
    gst_buffer_unref (*outbuf);
    *outbuf = NULL;
    return GST_FLOW_ERROR;
  }
}
コード例 #24
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
/* PUT conditional on bogus lock-token and valid etag, should fail. */
static int fail_cond_put_unlocked(void)
{
    int klass, code;

    CALL(conditional_put("(<DAV:no-lock>)", &klass, &code));

    ONV(klass == 2,
        ("conditional PUT with invalid lock-token should fail: %s",
         ne_get_error(i_session)));

    ONN("conditional PUT with invalid lock-token code got 400", code == 400);

    if (code != 412) 
	t_warning("PUT failed with %d not 412", code);

    return OK;
}
コード例 #25
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
/* indirectly refresh the the collection lock */
static int indirect_refresh(void)
{
    struct ne_lock *indirect;

    PRECOND(gotlock);

    indirect = ne_lock_copy(gotlock);
    ne_free(indirect->uri.path);
    indirect->uri.path = ne_strdup(res);

    ONV(ne_lock_refresh(i_session, indirect),
        ("indirect refresh LOCK on %s via %s: %s",
         coll, res, ne_get_error(i_session)));

    ne_lock_destroy(indirect);

    return OK;    
}
コード例 #26
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
/* PUT conditional on real lock-token and not(bogus lock-token),
 * should succeed. */
static int cond_put_with_not(void)
{
    int klass, code;
    char hdr[200];

    PRECOND(gotlock);

    ne_snprintf(hdr, sizeof hdr, "(<%s>) (Not <DAV:no-lock>)", 
                gotlock->token);
    
    CALL(conditional_put(hdr, &klass, &code));

    ONV(klass != 2,
        ("PUT with conditional (Not <DAV:no-lock>) failed: %s",
         ne_get_error(i_session)));

    return OK;
}
コード例 #27
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
/* a PUT conditional on lock and etag should succeed */
static int cond_put(void)
{
    char *etag = get_etag(res);
    char hdr[200];
    int klass;

    PRECOND(etag && gotlock);
    
    ne_snprintf(hdr, sizeof hdr, "(<%s> [%s])", gotlock->token, etag);
    
    CALL(conditional_put(hdr, &klass, NULL));

    ONV(klass != 2, 
        ("PUT conditional on lock and etag failed: %s",
         ne_get_error(i_session)));

    return OK;
}
コード例 #28
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
/* lock on unmapped url should return 201 */
static int unmapped_lock(void)
{
    if (gotlock) {
        ne_lock_destroy(gotlock);
        gotlock = NULL;
    }
    ne_free(res);

    res = ne_concat(i_path, "unmapped_url", NULL);

    ONV(getlock(ne_lockscope_exclusive, NE_DEPTH_ZERO),
        ("LOCK on %s via %s: %s",
         coll, res, ne_get_error(i_session)));

    if (STATUS(201)) 
	t_warning("LOCK on unmapped url returned %d not 201 (RFC4918:S7.3)", GETSTATUS);

    return OK;
}
コード例 #29
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
static int owner_modify(void)
{
    PRECOND(gotlock);
    ne_proppatch_operation pops[] = {
        { NULL, ne_propset, "foobar" },
        { NULL }
    };
    const ne_propname pname = { "http://webdav.org/neon/litmus/", "random" };
    
    pops[0].name = &pname;

    ONV(ne_put(i_session, res, i_foo_fd),
	("PUT on locked resource failed: %s", ne_get_error(i_session)));

    ONMREQ("PROPPATCH on locked resouce", res,
           ne_proppatch(i_session, res, pops));
    
    return OK;
}
コード例 #30
0
ファイル: locks.c プロジェクト: foswiki/WebDAVContrib
/* PUT with a conditional (lock-token and etag) (Not bogus-token and etag) */
static int complex_cond_put(void)
{
    int klass, code;
    char hdr[200];
    char *etag = get_etag(res);

    PRECOND(gotlock && etag != NULL);

    ne_snprintf(hdr, sizeof hdr, "(<%s> [%s]) (Not <DAV:no-lock> [%s])", 
                gotlock->token, etag, etag);
    
    CALL(conditional_put(hdr, &klass, &code));

    ONV(klass != 2,
        ("PUT with complex conditional failed: %s",
         ne_get_error(i_session)));

    return OK;
}