{"thread":{"id":"17228","subject":"[PATCH 1/2] http-push: send opaquelocktoken in If: for PUT requests","startedAt":"2009-01-17T20:10:28Z","lastAt":"2009-01-17T20:14:47Z","messageCount":2,"participants":["Ray Chuan"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"100878","messageId":"be6fef0d0901171210o97a24carf902e82848d48b5d@mail.gmail.com","threadId":"17228","inReplyTo":null,"subject":"[PATCH 1/2] http-push: send opaquelocktoken in If: for PUT requests","fromName":"Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-01-17T20:10:28Z","receivedAt":"2009-01-17T20:10:28Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Currently, git PUTs to\n\n  /repo.git/objects/1a/1a2b...9z_opaquelocktoken:1234-....\n\nOn some platforms, ':' isn't allowed in filenames so the PUT fails.\nThis seems to be an (faulty) implementation of the opaquelocktoken URI\nscheme (http://www.webdav.org/specs/rfc4918.html#RFC2518).\n\nPUT now sends the object to the url\n\n  /repo.git/objects/1a/1a2b...9z\n\n, without the trailing '_opaquelocktoken:1234-....', with an\nadditional \"If: (<opaquelocktoken:1234-....>)\" header.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http-push.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex c9ba07e..4517cf2 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -480,7 +480,9 @@ static void start_put(struct transfer_request *request)\n {\n \tchar *hex = sha1_to_hex(request->obj->sha1);\n \tstruct active_request_slot *slot;\n+\tstruct curl_slist *dav_headers = NULL;\n \tchar *posn;\n+\tchar *if_header;\n \tenum object_type type;\n \tchar hdr[50];\n \tvoid *unpacked;\n@@ -535,6 +537,10 @@ static void start_put(struct transfer_request *request)\n \t*(posn++) = '_';\n \tstrcpy(posn, request->lock->token);\n\n+\tif_header = xmalloc(strlen(request->lock->token) + 25);\n+\tsprintf(if_header, \"If: <%s>\", request->lock->token);\n+\tdav_headers = curl_slist_append(dav_headers, if_header);\n+\n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n \tslot->callback_data = request;\n@@ -546,6 +552,7 @@ static void start_put(struct transfer_request *request)\n \tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n \tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n \tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n\n \tif (start_active_slot(slot)) {\n-- \n1.5.6.3\n"},{"id":"100879","messageId":"be6fef0d0901171214h44b80a5drd2dd11f2bd65cf53@mail.gmail.com","threadId":"17228","inReplyTo":"be6fef0d0901171210o97a24carf902e82848d48b5d@mail.gmail.com","subject":"Re: [PATCH 1/2] http-push: send opaquelocktoken in If: for PUT requests","fromName":"Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-01-17T20:14:47Z","receivedAt":"2009-01-17T20:14:47Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"oops, i incorrectly stated in the commit message that the request URL\nfor PUT was modified; i apologize for that error.\n\nOn 1/17/09, Ray Chuan <rctay89@gmail.com> wrote:\n> Currently, git PUTs to\n>\n>   /repo.git/objects/1a/1a2b...9z_opaquelocktoken:1234-....\n>\n> On some platforms, ':' isn't allowed in filenames so the PUT fails.\n> This seems to be an (faulty) implementation of the opaquelocktoken URI\n> scheme (http://www.webdav.org/specs/rfc4918.html#RFC2518).\n>\n> PUT now sends the object to the url\n>\n>   /repo.git/objects/1a/1a2b...9z\n>\n> , without the trailing '_opaquelocktoken:1234-....', with an\n> additional \"If: (<opaquelocktoken:1234-....>)\" header.\n>\n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n>  http-push.c |    7 +++++++\n>  1 files changed, 7 insertions(+), 0 deletions(-)\n>\n> diff --git a/http-push.c b/http-push.c\n> index c9ba07e..4517cf2 100644\n> --- a/http-push.c\n> +++ b/http-push.c\n> @@ -480,7 +480,9 @@ static void start_put(struct transfer_request *request)\n>  {\n>  \tchar *hex = sha1_to_hex(request->obj->sha1);\n>  \tstruct active_request_slot *slot;\n> +\tstruct curl_slist *dav_headers = NULL;\n>  \tchar *posn;\n> +\tchar *if_header;\n>  \tenum object_type type;\n>  \tchar hdr[50];\n>  \tvoid *unpacked;\n> @@ -535,6 +537,10 @@ static void start_put(struct transfer_request *request)\n>  \t*(posn++) = '_';\n>  \tstrcpy(posn, request->lock->token);\n>\n> +\tif_header = xmalloc(strlen(request->lock->token) + 25);\n> +\tsprintf(if_header, \"If: <%s>\", request->lock->token);\n> +\tdav_headers = curl_slist_append(dav_headers, if_header);\n> +\n>  \tslot = get_active_slot();\n>  \tslot->callback_func = process_response;\n>  \tslot->callback_data = request;\n> @@ -546,6 +552,7 @@ static void start_put(struct transfer_request *request)\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_PUT, 1);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n>\n>  \tif (start_active_slot(slot)) {\n> --\n> 1.5.6.3\n>\n\n\n-- \nCheers,\nRay Chuan\n"}]}