Congbin Guo | 31bd1a1 | 2020-06-02 17:47:13 -0700 | [diff] [blame^] | 1 | # -*- 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 | |
| 8 | This is a short term solution in order to deprecation devserver.py from labs. |
| 9 | """ |
| 10 | from __future__ import absolute_import |
| 11 | from __future__ import division |
| 12 | from __future__ import print_function |
| 13 | |
| 14 | import cherrypy |
| 15 | |
| 16 | |
| 17 | def 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 |
| 27 | class 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) |