blob: 6af530741864918faa3567b60f7401dea5940aeb [file] [log] [blame]
Congbin Guo31bd1a12020-06-02 17:47:13 -07001# -*- coding: utf-8 -*-
2# Copyright 2020 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""An cherry app to play as a fake Omaha service.
7
8This is a short term solution in order to deprecation devserver.py from labs.
9"""
10from __future__ import absolute_import
11from __future__ import division
12from __future__ import print_function
13
14import cherrypy
15
16
17def get_config():
18 """Get cherrypy config for this application."""
19 return {
20 '/': {
21 'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
22 }
23 }
24
25
26@cherrypy.expose
27class FakeOmaha(object):
28 """An application to handle fake Omaha requests."""
29 def POST(self, *args, **kwargs):
30 """A URL handler to handle update check ping."""
31 body_length = int(cherrypy.request.headers.get('Content-Length', 0))
32 data = cherrypy.request.rfile.read(body_length)
33 return 'Fake Omaha: To be implemented\nArgs: %s\nkwargs: %s\nData: %s\n' % (
34 args, kwargs, data)