Repository: zulip/zulip

Issue:
Preview feature doesn't work with long messages
If you put this message into the compose box and click the preview button, it doesn't work, because we try to send the entire message body as a GET URL parameter, and we overflow maximum lengths for those.

We should move this into the body of the request (probably means switching it to POST), not URL parameters.

```
012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678_012345678901234567890123456789012345678
```


Discussion:

Resolving patch:
diff --git a/api/zulip/__init__.py b/api/zulip/__init__.py
--- a/api/zulip/__init__.py
+++ b/api/zulip/__init__.py
@@ -681,7 +681,7 @@ def render_message(self, request=None):
         '''
         return self.call_endpoint(
             url='messages/render',
-            method='GET',
+            method='POST',
             request=request,
         )
 
diff --git a/zproject/urls.py b/zproject/urls.py
--- a/zproject/urls.py
+++ b/zproject/urls.py
@@ -213,7 +213,7 @@
         {'GET': 'zerver.views.messages.json_fetch_raw_message',
          'PATCH': 'zerver.views.messages.json_update_message'}),
     url(r'^messages/render$', rest_dispatch,
-        {'GET': 'zerver.views.messages.render_message_backend'}),
+        {'POST': 'zerver.views.messages.render_message_backend'}),
     url(r'^messages/flags$', rest_dispatch,
         {'POST': 'zerver.views.messages.update_message_flags'}),
 


Test patch:
diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py
--- a/zerver/tests/test_bugdown.py
+++ b/zerver/tests/test_bugdown.py
@@ -839,7 +839,7 @@ class BugdownApiTests(ZulipTestCase):
     def test_render_message_api(self):
         # type: () -> None
         content = 'That is a **bold** statement'
-        result = self.client_get(
+        result = self.client_post(
             '/api/v1/messages/render',
             dict(content=content),
             **self.api_auth('othello@zulip.com')
@@ -853,7 +853,7 @@ def test_render_mention_stream_api(self):
         # type: () -> None
         """Determines whether we're correctly passing the realm context"""
         content = 'This mentions #**Denmark** and @**King Hamlet**.'
-        result = self.client_get(
+        result = self.client_post(
             '/api/v1/messages/render',
             dict(content=content),
             **self.api_auth('othello@zulip.com')