File indexing completed on 2024-05-19 15:46:48
0001 #!/usr/bin/env python3 0002 # -*- coding: utf-8 -*- 0003 # 0004 # SPDX-FileCopyrightText: 2014 Denis Steckelmacher <steckdenis@yahoo.fr> 0005 # 0006 # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0007 0008 from jsgenerator import * 0009 from common import * 0010 0011 # Print the license of the generated file (the same as the one of this file) 0012 license() 0013 basicTypes(globals()) 0014 require('event') 0015 require('net') 0016 0017 _function = 'function(){}' 0018 _object = 'new Object()' 0019 _date = 'new Date()' 0020 0021 Module().members( 0022 Var('{}', 'STATUS_CODES'), 0023 F('new Server()', 'createServer', ('requestListener', _function)), 0024 F('new Client()', 'createClient', ('port', _int), ('host', _string)), 0025 Class('Server').prototype('event.EventEmitter').members( 0026 F(_void, 'listen', ('port', _int), ('hostname', _string), ('backlog', _int), ('callback', _function)), 0027 F(_void, 'close', ('callback', _function)), 0028 Var(_int, 'maxHeadersCount'), 0029 F(_void, 'setTimeout', ('msecs', _int), ('callback', _function)), 0030 Var(_int, 'timeout'), 0031 ), 0032 Class('ServerResponse').prototype('event.EventEmitter').members( 0033 F(_void, 'writeContinue'), 0034 F(_void, 'writeHead', ('statusCode', _int), ('reasonPhrase', _string), ('headers', _object)), 0035 F(_void, 'setTimeout', ('msecs', _int), ('callback', _function)), 0036 Var(_int, 'statusCode'), 0037 F(_void, 'setHeader', ('name', _string), ('value', _string)), 0038 Var(_bool, 'headersSent'), 0039 Var(_bool, 'sendDate'), 0040 F(_string, 'getHeader', ('name', _string)), 0041 F(_void, 'removeHeader', ('name', _string)), 0042 F(_bool, 'write', ('chunk', _string), ('encoding', _string)), 0043 F(_void, 'addTrailers', ('headers', _object)), 0044 F(_void, 'end', ('data', _string), ('encoding', _string)) 0045 ), 0046 F('new ClientRequest()', 'request', ('options', _object), ('callback', _function)), 0047 F('new ClientRequest()', 'get', ('options', _object), ('callback', _function)), 0048 Class('Agent').members( 0049 Var(_int, 'maxSockets'), 0050 Var(_array, 'sockets'), 0051 Var(_array, 'requests') 0052 ), 0053 Var('new Agent()', 'globalAgent'), 0054 Class('ClientRequest').prototype('event.EventEmitter').members( 0055 F(_void, 'write', ('chunk', _string), ('encoding', _string)), 0056 F(_void, 'end', ('data', _string), ('encoding', _string)), 0057 F(_void, 'abort'), 0058 F(_void, 'setTimeout', ('msecs', _int), ('callback', _function)), 0059 F(_void, 'setNoDelay', ('noDelay', _bool)), 0060 F(_void, 'setSocketKeepAlive', ('enable', _bool), ('initialDelay', _int)), 0061 ), 0062 Class('IncomingMessage').prototype('event.EventEmitter').members( 0063 Var(_string, 'httpVersion'), 0064 Var(_object, 'headers'), 0065 Var(_object, 'trailers'), 0066 F(_void, 'setTimeout', ('msecs', _int), ('callback', _function)), 0067 Var(_string, 'method'), 0068 Var(_string, 'url'), 0069 Var(_int, 'statusCode'), 0070 Var('new net.Socket()', 'socket') 0071 ) 0072 ).print()