From b790d0ba0332a621d0b58cfd69fa13bd3dc358d2 Mon Sep 17 00:00:00 2001 From: Andrew Bonventre Date: Thu, 4 Jan 2018 22:24:33 -0500 Subject: [PATCH] godoc: set proper content-type header on share request When sending the request to /share, it defaulted to application/x-www-form-urlencoded. This caused the body to be empty since it was sending a form with the actual code as a key in the r.Form map. Set the content type explicitly to text/plain. Fixes golang/go#21691 Change-Id: I0d5981d9c9aa901010af65b0d0a7670870b77f2b Reviewed-on: https://go-review.googlesource.com/86317 Reviewed-by: Andrew Bonventre --- godoc/static/playground.js | 1 + godoc/static/static.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/godoc/static/playground.js b/godoc/static/playground.js index bea9c4b6..51b00a43 100644 --- a/godoc/static/playground.js +++ b/godoc/static/playground.js @@ -403,6 +403,7 @@ function PlaygroundOutput(el) { processData: false, data: sharingData, type: "POST", + contentType: "text/plain; charset=utf-8", complete: function(xhr) { sharing = false; if (xhr.status != 200) { diff --git a/godoc/static/static.go b/godoc/static/static.go index 8197d894..0711e51e 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -1,4 +1,4 @@ -// Copyright 2017 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -2599,6 +2599,7 @@ function PlaygroundOutput(el) { processData: false, data: sharingData, type: "POST", + contentType: "text/plain; charset=utf-8", complete: function(xhr) { sharing = false; if (xhr.status != 200) {