/* Creator callback for private structure. */ static void *ld_create(void *userdata, const ne_uri *uri) { struct ne_lock *lk = ne_lock_create(); ne_uri_copy(&lk->uri, uri); return lk; }
struct ne_lock *ne_lock_copy(const struct ne_lock *lock) { struct ne_lock *ret = ne_calloc(sizeof *ret); ne_uri_copy(&ret->uri, &lock->uri); ret->token = ne_strdup(lock->token); ret->depth = lock->depth; ret->type = lock->type; ret->scope = lock->scope; if (lock->owner) ret->owner = ne_strdup(lock->owner); ret->timeout = lock->timeout; return ret; }
static int open_request (struct neon_handle * handle, uint64_t startbyte) { int ret; const ne_status * status; ne_uri * rediruri; if (handle->purl->query && * (handle->purl->query)) { SCONCAT3 (tmp, handle->purl->path, "?", handle->purl->query); handle->request = ne_request_create (handle->session, "GET", tmp); } else handle->request = ne_request_create (handle->session, "GET", handle->purl->path); if (startbyte > 0) ne_print_request_header (handle->request, "Range", "bytes=%"PRIu64"-", startbyte); ne_print_request_header (handle->request, "Icy-MetaData", "1"); /* Try to connect to the server. */ _DEBUG ("<%p> Connecting...", handle); ret = ne_begin_request (handle->request); status = ne_get_status (handle->request); _DEBUG ("<%p> Return: %d, Status: %d", handle, ret, status->code); if (ret == NE_OK) { switch (status->code) { case 401: /* Authorization required. Reconnect to authenticate */ _DEBUG ("Reconnecting due to 401"); ne_end_request (handle->request); ret = ne_begin_request (handle->request); break; case 301: case 302: case 303: case 307: /* Redirect encountered. Reconnect. */ ne_end_request (handle->request); ret = NE_REDIRECT; break; case 407: /* Proxy auth required. Reconnect to authenticate */ _DEBUG ("Reconnecting due to 407"); ne_end_request (handle->request); ret = ne_begin_request (handle->request); break; } } switch (ret) { case NE_OK: if (status->code > 199 && status->code < 300) { /* URL opened OK */ _DEBUG ("<%p> URL opened OK", handle); handle->content_start = startbyte; handle->pos = startbyte; handle_headers (handle); return 0; } break; case NE_REDIRECT: /* We hit a redirect. Handle it. */ _DEBUG ("<%p> Redirect encountered", handle); handle->redircount += 1; rediruri = (ne_uri *) ne_redirect_location (handle->session); ne_request_destroy (handle->request); handle->request = NULL; if (! rediruri) { _ERROR ("<%p> Could not parse redirect response", (void *) handle); return -1; } ne_uri_free (handle->purl); ne_uri_copy (handle->purl, rediruri); return 1; } /* Something went wrong. */ _ERROR ("<%p> Could not open URL: %d (%d)", (void *) handle, ret, status->code); if (ret) _ERROR ("<%p> neon error string: %s", (void *) handle, ne_get_error (handle->session)); ne_request_destroy (handle->request); handle->request = NULL; return -1; }