View | Details | Raw Unified | Return to bug 26268 | Differences between
and this patch

Collapse All | Expand All

(-)univention-management-console-web-server (-5 / +19 lines)
 Lines 32-37    Link Here 
32
# <http://www.gnu.org/licenses/>.
32
# <http://www.gnu.org/licenses/>.
33
33
34
import cherrypy
34
import cherrypy
35
import httplib
35
import os
36
import os
36
import threading
37
import threading
37
import Queue
38
import Queue
 Lines 42-49    Link Here 
42
import tempfile
43
import tempfile
43
import time
44
import time
44
import threading
45
import threading
46
import urllib
47
import urlparse
45
import uuid
48
import uuid
46
import httplib
47
49
48
import notifier
50
import notifier
49
from daemon.runner import DaemonRunner, DaemonRunnerStopFailureError, DaemonRunnerStartFailureError
51
from daemon.runner import DaemonRunner, DaemonRunnerStopFailureError, DaemonRunnerStartFailureError
 Lines 349-354    Link Here 
349
				except ValueError:
351
				except ValueError:
350
					self._log('error', 'cannot parse JSON body')
352
					self._log('error', 'cannot parse JSON body')
351
					raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'Invalid JSON document')
353
					raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'Invalid JSON document')
354
		else:
355
			json = ''
352
356
353
		# create new UMCP request
357
		# create new UMCP request
354
		req = self.get_request( cherrypy.request, json )
358
		req = self.get_request( cherrypy.request, json )
 Lines 371-376    Link Here 
371
				return '<html><body><textarea>' + simplejson.dumps(response.body) + '</textarea></body></html>'
375
				return '<html><body><textarea>' + simplejson.dumps(response.body) + '</textarea></body></html>'
372
			else:
376
			else:
373
				return simplejson.dumps(response.body)
377
				return simplejson.dumps(response.body)
378
		elif response.mimetype != umcp.MIMETYPE_JSON:
379
			update_session_cookie(cherrypy.response.cookie, sessionid)
380
			cherrypy.response.headers[ 'Content-Type' ] = response.mimetype
381
			return response.body
374
382
375
		# something bad happened
383
		# something bad happened
376
		self._log('error', 'response status code: %s' % response.status)
384
		self._log('error', 'response status code: %s' % response.status)
 Lines 433-439    Link Here 
433
	requestprefix = '/command'
441
	requestprefix = '/command'
434
442
435
	def get_request(self, request, json):
443
	def get_request(self, request, json):
436
		args = request.path_info
444
		parse_result = urlparse.urlparse( request.path_info )
445
		args = parse_result.path
437
446
438
		if args.startswith( self.requestprefix ):
447
		if args.startswith( self.requestprefix ):
439
			args = args[ len(self.requestprefix)+1 : ]
448
			args = args[ len(self.requestprefix)+1 : ]
 Lines 442-450    Link Here 
442
			self._log('error', 'get_request: args is empty')
451
			self._log('error', 'get_request: args is empty')
443
			raise cherrypy.HTTPError(httplib.NOT_FOUND)
452
			raise cherrypy.HTTPError(httplib.NOT_FOUND)
444
453
445
		req = umcp.Command( [ args ], options = json.get( 'options', {} ) )
454
		if cherrypy.request.method == 'POST':
446
		if 'flavor' in json:
455
			req = umcp.Command( [ args ], options = json.get( 'options', {} ) )
447
			req.flavor = json[ 'flavor' ]
456
			if 'flavor' in json:
457
				req.flavor = json[ 'flavor' ]
458
		elif cherrypy.request.method == 'GET':
459
			req = umcp.Command( [ args ], options = {} )
460
			for key, value in urlparse.parse_qsl( cherrypy.request.query_string ):
461
				req.options[ key ] = urllib.unquote( value )
448
462
449
		return req
463
		return req
450
464

Return to bug 26268