All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] http-push: send opaquelocktoken in If: for PUT requests
@ 2009-01-17 20:10 Ray Chuan
  2009-01-17 20:14 ` Ray Chuan
  0 siblings, 1 reply; 2+ messages in thread
From: Ray Chuan @ 2009-01-17 20:10 UTC (permalink / raw
  To: git

Currently, git PUTs to

  /repo.git/objects/1a/1a2b...9z_opaquelocktoken:1234-....

On some platforms, ':' isn't allowed in filenames so the PUT fails.
This seems to be an (faulty) implementation of the opaquelocktoken URI
scheme (http://www.webdav.org/specs/rfc4918.html#RFC2518).

PUT now sends the object to the url

  /repo.git/objects/1a/1a2b...9z

, without the trailing '_opaquelocktoken:1234-....', with an
additional "If: (<opaquelocktoken:1234-....>)" header.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 http-push.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/http-push.c b/http-push.c
index c9ba07e..4517cf2 100644
--- a/http-push.c
+++ b/http-push.c
@@ -480,7 +480,9 @@ static void start_put(struct transfer_request *request)
 {
 	char *hex = sha1_to_hex(request->obj->sha1);
 	struct active_request_slot *slot;
+	struct curl_slist *dav_headers = NULL;
 	char *posn;
+	char *if_header;
 	enum object_type type;
 	char hdr[50];
 	void *unpacked;
@@ -535,6 +537,10 @@ static void start_put(struct transfer_request *request)
 	*(posn++) = '_';
 	strcpy(posn, request->lock->token);

+	if_header = xmalloc(strlen(request->lock->token) + 25);
+	sprintf(if_header, "If: <%s>", request->lock->token);
+	dav_headers = curl_slist_append(dav_headers, if_header);
+
 	slot = get_active_slot();
 	slot->callback_func = process_response;
 	slot->callback_data = request;
@@ -546,6 +552,7 @@ static void start_put(struct transfer_request *request)
 	curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
 	curl_easy_setopt(slot->curl, CURLOPT_PUT, 1);
 	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
+	curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
 	curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);

 	if (start_active_slot(slot)) {
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] http-push: send opaquelocktoken in If: for PUT requests
  2009-01-17 20:10 [PATCH 1/2] http-push: send opaquelocktoken in If: for PUT requests Ray Chuan
@ 2009-01-17 20:14 ` Ray Chuan
  0 siblings, 0 replies; 2+ messages in thread
From: Ray Chuan @ 2009-01-17 20:14 UTC (permalink / raw
  To: git

oops, i incorrectly stated in the commit message that the request URL
for PUT was modified; i apologize for that error.

On 1/17/09, Ray Chuan <rctay89@gmail.com> wrote:
> Currently, git PUTs to
>
>   /repo.git/objects/1a/1a2b...9z_opaquelocktoken:1234-....
>
> On some platforms, ':' isn't allowed in filenames so the PUT fails.
> This seems to be an (faulty) implementation of the opaquelocktoken URI
> scheme (http://www.webdav.org/specs/rfc4918.html#RFC2518).
>
> PUT now sends the object to the url
>
>   /repo.git/objects/1a/1a2b...9z
>
> , without the trailing '_opaquelocktoken:1234-....', with an
> additional "If: (<opaquelocktoken:1234-....>)" header.
>
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
> ---
>  http-push.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/http-push.c b/http-push.c
> index c9ba07e..4517cf2 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -480,7 +480,9 @@ static void start_put(struct transfer_request *request)
>  {
>  	char *hex = sha1_to_hex(request->obj->sha1);
>  	struct active_request_slot *slot;
> +	struct curl_slist *dav_headers = NULL;
>  	char *posn;
> +	char *if_header;
>  	enum object_type type;
>  	char hdr[50];
>  	void *unpacked;
> @@ -535,6 +537,10 @@ static void start_put(struct transfer_request *request)
>  	*(posn++) = '_';
>  	strcpy(posn, request->lock->token);
>
> +	if_header = xmalloc(strlen(request->lock->token) + 25);
> +	sprintf(if_header, "If: <%s>", request->lock->token);
> +	dav_headers = curl_slist_append(dav_headers, if_header);
> +
>  	slot = get_active_slot();
>  	slot->callback_func = process_response;
>  	slot->callback_data = request;
> @@ -546,6 +552,7 @@ static void start_put(struct transfer_request *request)
>  	curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
>  	curl_easy_setopt(slot->curl, CURLOPT_PUT, 1);
>  	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
> +	curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
>  	curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
>
>  	if (start_active_slot(slot)) {
> --
> 1.5.6.3
>


-- 
Cheers,
Ray Chuan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-17 20:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-17 20:10 [PATCH 1/2] http-push: send opaquelocktoken in If: for PUT requests Ray Chuan
2009-01-17 20:14 ` Ray Chuan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.