Skip to content

Commit

Permalink
added Content-Type header to all requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkusher committed Aug 21, 2016
1 parent 0407fb4 commit 46152ec
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions padawan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import re

urllib2 = urllib.request

def get_setting(name, default=None):
project_data = sublime.active_window().project_data()
Expand Down Expand Up @@ -45,10 +46,12 @@ def restart(self):
def sendRequest(self, command, params, data=''):
timeout = get_setting("padawan_timeout", 0.5)
addr = server_addr + "/"+command+"?" + urllib.parse.urlencode(params)
response = urllib.request.urlopen(
addr,
data.encode("utf8"),
timeout
request = urllib2.Request(addr, headers={
"Content-Type": "plain/text"
}, data = data.encode("utf8"))
response = urllib2.urlopen(
request,
timeout=timeout
)
result = json.loads(response.read().decode("utf8"))
if "error" in result:
Expand Down Expand Up @@ -124,7 +127,7 @@ def DoRequest(self, command, params, data=''):
except urllib.request.URLError:
editor.error("Padawan.php is not running")
except Exception as e:
editor.error("Error occured {0}".format(e.message))
editor.error("Error occured {0}".format(e))

return False

Expand Down

0 comments on commit 46152ec

Please sign in to comment.