{"thread":{"id":"28579","subject":"[PATCH] remote-curl: Fix warning after HTTP failure","startedAt":"2011-10-04T23:20:19Z","lastAt":"2011-10-04T23:20:19Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"176891","messageId":"1317770419-24403-1-git-send-email-spearce@spearce.org","threadId":"28579","inReplyTo":null,"subject":"[PATCH] remote-curl: Fix warning after HTTP failure","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2011-10-04T23:20:19Z","receivedAt":"2011-10-04T23:20:19Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"From: \"Shawn O. Pearce\" <spearce@spearce.org>\n\nIf the HTTP connection is broken in the middle of a fetch or clone\nbody, the client presented a useless error message due to part of\nthe upload-pack->remote-curl pkt-line protocol leaking out of the\nhelper as the helper's \"fetch result\":\n\n  error: RPC failed; result=18, HTTP code = 200\n  fatal: The remote end hung up unexpectedly\n  fatal: early EOF\n  fatal: unpack-objects failed\n  warning: https unexpectedly said: '0000'\n\nInstead when the HTTP RPC fails discard all remaining data from\nupload-pack and report nothing to the transport helper. Errors\nwere already sent to stderr.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n remote-curl.c |   11 ++++++++++-\n 1 files changed, 10 insertions(+), 1 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 69831e9..d2bf832 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -573,7 +573,16 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)\n \n \tclose(client.in);\n \tclient.in = -1;\n-\tstrbuf_read(&rpc->result, client.out, 0);\n+\tif (!err) {\n+\t  strbuf_read(&rpc->result, client.out, 0);\n+\t} else {\n+\t\tchar buf[4096];\n+\t\tfor (;;) {\n+\t\t\tint n = read(client.out, buf, sizeof(buf));\n+\t\t\tif (n <= 0)\n+\t\t\t  break;\n+\t\t}\n+\t}\n \n \tclose(client.out);\n \tclient.out = -1;\n-- \n1.7.6.4.dirty\n"}]}