get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/811756/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 811756,
    "url": "http://patchwork.ozlabs.org/api/patches/811756/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170908173801.15205-7-brandon.carpenter@cypherpath.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170908173801.15205-7-brandon.carpenter@cypherpath.com>",
    "list_archive_url": null,
    "date": "2017-09-08T17:38:01",
    "name": "[v2,6/6] io: Reply to ping frames",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "9c42fed134cd0d3286f04ba0bfff94a2b9be2e80",
    "submitter": {
        "id": 72031,
        "url": "http://patchwork.ozlabs.org/api/people/72031/?format=api",
        "name": "Brandon Carpenter",
        "email": "brandon.carpenter@cypherpath.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170908173801.15205-7-brandon.carpenter@cypherpath.com/mbox/",
    "series": [
        {
            "id": 2262,
            "url": "http://patchwork.ozlabs.org/api/series/2262/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2262",
            "date": "2017-09-08T17:37:56",
            "name": "Update websocket code to more fully support the RFC",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/2262/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/811756/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/811756/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=cypherpath.com header.i=@cypherpath.com\n\theader.b=\"Y0QgovXz\"; dkim-atps=neutral"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xplGy69Kyz9s2G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 03:50:50 +1000 (AEST)",
            "from localhost ([::1]:46737 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dqNQW-0002PF-RV\n\tfor incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 13:50:48 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:40147)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1dqNFR-0000Mc-VS\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:23 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1dqNFQ-0008MB-NC\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:22 -0400",
            "from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]:37686)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <brandon.carpenter@cypherpath.com>)\n\tid 1dqNFQ-0008LM-F2\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 13:39:20 -0400",
            "by mail-pg0-x22e.google.com with SMTP id d8so5918000pgt.4\n\tfor <qemu-devel@nongnu.org>; Fri, 08 Sep 2017 10:39:20 -0700 (PDT)",
            "from servo.cypherpath.com (68-113-0-218.static.knwc.wa.charter.com.\n\t[68.113.0.218]) by smtp.gmail.com with ESMTPSA id\n\tc30sm4556833pgn.33.2017.09.08.10.39.18\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 10:39:18 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=cypherpath.com; s=google;\n\th=mime-version:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:in-reply-to:references;\n\tbh=ceQl8Hh0r9b20YeK93b9UsGibxD8vOPnOJvLvw8wO34=;\n\tb=Y0QgovXzsAFPNUPUy4kHQu92MpOkNiO1kGevTPKIccXo7aMbfVSDVubE6Gzkg3keU/\n\tZbVvxnekm5KtyKK0I4uecG/BjgV/eLGAGNRQSFpG9NO/PbUB5ZY/eB7rOe1RDCWsRcyF\n\tWFxv2GRDlmEIgE37jjLrxE2Qs1r06h4ZeyTzE=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:in-reply-to:references;\n\tbh=ceQl8Hh0r9b20YeK93b9UsGibxD8vOPnOJvLvw8wO34=;\n\tb=Zy4PuxOEawCto7d3yjvuCkiP8gR37P0gnYMtiaIzVTK562/DwOf6D4Yn6kU2LrLnpu\n\tMKoc2As2PhE7YDWq/sEhqb4FtwBJHTgJmKsCxwfgMhGwETcD+Ryb2ygUIFGmaAam2plj\n\tmL7MZJ2wzRsd0xXabN6m7InKPoDrcIhMGpQ3yNlyypgoGdnmVy8q6pkprfnESxlib+6m\n\tGhVRSlGqPho20NfRGwQwiB/O3fIMhS3Mwjufy7gPp80IWuFlrmqjbCpaSH0wytSsuxS0\n\ta2HUPNer0U73RwTdfqpo5dAl+S6wknC0Jt1dEiIk0K2jHgLij94yU/KVjjQVXEcwcOV0\n\tRZDg==",
        "X-Gm-Message-State": "AHPjjUjzXSoYNzkWUS9CYx9QW7tA4+fcFptkvqm72iZ++JiE/4J6qnMf\n\t0Nb90H1X27/2wa6kGszfQN0/xo4La7opmrYk0fTNd28jG6pKZY3RYO7cbmyJLkM/U4J5gxl21T6\n\tXtBAw",
        "MIME-Version": "1.0",
        "X-Google-Smtp-Source": "ADKCNb5vJUGBxdTNZXpor2ZU4rgd4+My9v/Tmzzv9mnBwLIbKTGQvhOlqeXjoO2QGYEOtPC4Mj0liA==",
        "X-Received": "by 10.98.102.20 with SMTP id a20mr3965690pfc.208.1504892359250; \n\tFri, 08 Sep 2017 10:39:19 -0700 (PDT)",
        "From": "Brandon Carpenter <brandon.carpenter@cypherpath.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Fri,  8 Sep 2017 10:38:01 -0700",
        "Message-Id": "<20170908173801.15205-7-brandon.carpenter@cypherpath.com>",
        "X-Mailer": "git-send-email 2.14.1",
        "In-Reply-To": [
            "<20170908173801.15205-1-brandon.carpenter@cypherpath.com>",
            "<20170724184217.21381-1-brandon.carpenter@cypherpath.com>"
        ],
        "References": [
            "<20170908173801.15205-1-brandon.carpenter@cypherpath.com>",
            "<20170724184217.21381-1-brandon.carpenter@cypherpath.com>"
        ],
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "X-detected-operating-system": "by eggs.gnu.org: Genre and OS details not\n\trecognized.",
        "X-Received-From": "2607:f8b0:400e:c05::22e",
        "Subject": "[Qemu-devel] [PATCH v2 6/6] io: Reply to ping frames",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "brandon.carpenter@cypherpath.com",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "Add an immediate ping reply (pong) to the outgoing stream when a ping\nis received. Unsolicited pongs are ignored.\n\nSigned-off-by: Brandon Carpenter <brandon.carpenter@cypherpath.com>\n---\n io/channel-websock.c | 50 ++++++++++++++++++++++++++++++++------------------\n 1 file changed, 32 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/io/channel-websock.c b/io/channel-websock.c\nindex 50387050d5..175f17ce6b 100644\n--- a/io/channel-websock.c\n+++ b/io/channel-websock.c\n@@ -479,7 +479,8 @@ static gboolean qio_channel_websock_handshake_io(QIOChannel *ioc,\n }\n \n \n-static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n+static void qio_channel_websock_encode_buffer(QIOChannelWebsock *ioc,\n+                                              uint8_t opcode, Buffer *buffer)\n {\n     size_t header_size;\n     union {\n@@ -487,33 +488,37 @@ static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n         QIOChannelWebsockHeader ws;\n     } header;\n \n-    if (!ioc->rawoutput.offset) {\n-        return;\n-    }\n-\n     header.ws.b0 = QIO_CHANNEL_WEBSOCK_HEADER_FIELD_FIN |\n-        (QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME &\n-         QIO_CHANNEL_WEBSOCK_HEADER_FIELD_OPCODE);\n-    if (ioc->rawoutput.offset <\n+        (opcode & QIO_CHANNEL_WEBSOCK_HEADER_FIELD_OPCODE);\n+    if (buffer->offset <\n         QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_THRESHOLD_7_BIT) {\n-        header.ws.b1 = (uint8_t)ioc->rawoutput.offset;\n+        header.ws.b1 = (uint8_t)buffer->offset;\n         header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_7_BIT;\n-    } else if (ioc->rawoutput.offset <\n+    } else if (buffer->offset <\n                QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_THRESHOLD_16_BIT) {\n         header.ws.b1 = QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_16_BIT;\n-        header.ws.u.s16.l16 = cpu_to_be16((uint16_t)ioc->rawoutput.offset);\n+        header.ws.u.s16.l16 = cpu_to_be16((uint16_t)buffer->offset);\n         header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_16_BIT;\n     } else {\n         header.ws.b1 = QIO_CHANNEL_WEBSOCK_PAYLOAD_LEN_MAGIC_64_BIT;\n-        header.ws.u.s64.l64 = cpu_to_be64(ioc->rawoutput.offset);\n+        header.ws.u.s64.l64 = cpu_to_be64(buffer->offset);\n         header_size = QIO_CHANNEL_WEBSOCK_HEADER_LEN_64_BIT;\n     }\n     header_size -= QIO_CHANNEL_WEBSOCK_HEADER_LEN_MASK;\n \n-    buffer_reserve(&ioc->encoutput, header_size + ioc->rawoutput.offset);\n+    buffer_reserve(&ioc->encoutput, header_size + buffer->offset);\n     buffer_append(&ioc->encoutput, header.buf, header_size);\n-    buffer_append(&ioc->encoutput, ioc->rawoutput.buffer,\n-                  ioc->rawoutput.offset);\n+    buffer_append(&ioc->encoutput, buffer->buffer, buffer->offset);\n+}\n+\n+\n+static void qio_channel_websock_encode(QIOChannelWebsock *ioc)\n+{\n+    if (!ioc->rawoutput.offset) {\n+        return;\n+    }\n+    qio_channel_websock_encode_buffer(ioc,\n+            QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME, &ioc->rawoutput);\n     buffer_reset(&ioc->rawoutput);\n }\n \n@@ -558,7 +563,7 @@ static int qio_channel_websock_decode_header(QIOChannelWebsock *ioc,\n     /* Websocket frame sanity check:\n      * * Fragmentation is only supported for binary frames.\n      * * All frames sent by a client MUST be masked.\n-     * * Only binary encoding is supported.\n+     * * Only binary and ping/pong encoding is supported.\n      */\n     if (!fin) {\n         if (opcode != QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n@@ -619,6 +624,11 @@ static int qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n          * for purpose of unmasking, except at end of payload\n          */\n         if (ioc->encinput.offset < ioc->payload_remain) {\n+            /* Wait for the entire payload before processing control frames\n+             * because the payload will most likely be echoed back. */\n+            if (ioc->opcode & QIO_CHANNEL_WEBSOCK_CONTROL_OPCODE_MASK) {\n+                return QIO_CHANNEL_ERR_BLOCK;\n+            }\n             payload_len = ioc->encinput.offset - (ioc->encinput.offset % 4);\n         } else {\n             payload_len = ioc->payload_remain;\n@@ -641,13 +651,17 @@ static int qio_channel_websock_decode_payload(QIOChannelWebsock *ioc,\n         }\n     }\n \n-    /* Drop the payload of ping/pong packets */\n     if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME) {\n         if (payload_len) {\n+            /* binary frames are passed on */\n             buffer_reserve(&ioc->rawinput, payload_len);\n             buffer_append(&ioc->rawinput, ioc->encinput.buffer, payload_len);\n         }\n-    }\n+    } else if (ioc->opcode == QIO_CHANNEL_WEBSOCK_OPCODE_PING) {\n+        /* ping frames produce an immediate pong reply */\n+        qio_channel_websock_encode_buffer(ioc,\n+                QIO_CHANNEL_WEBSOCK_OPCODE_PONG, &ioc->encinput);\n+    }   /* pong frames are ignored */\n \n     if (payload_len) {\n         buffer_advance(&ioc->encinput, payload_len);\n",
    "prefixes": [
        "v2",
        "6/6"
    ]
}