OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
http_test Namespace Reference

Classes

class  State
class  HttpHandler
class  HttpServer
class  WsHandler
class  WsServer
class  Pinger

Functions

 ws_frame (opcode, payload, fin=True)
 make_certs (folder)
 tls_context (folder, name, max_version=None)
 start (server)
 wait_line (path, pattern, seconds)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
str MOD = 'httptest'
str CALLBACKS = 'maps/mp/gametypes/_callbacksetup.gsc'
str MARKER = '[[level.callbackStartGameType]]();'
str HOOK = 'thread maps\\mp\\gametypes\\_httptest::main();'
str WS_GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
str ERROR_CALLBACK
str TEST_SCRIPT
 STATE = State()
dict RAW_RESPONSES

Detailed Description

Tests httpFetch and webSocket* against local HTTP, HTTPS, WS and WSS servers.

    python3 scripts/http_test.py /path/to/CoD2 [--binary bin/cod2rev_lnxded]

The servers run in this process (Python standard library only; the HTTPS and
WSS certificates are made with the openssl command). A test script is
installed as a mod in a temporary folder, next to the game's own
_callbacksetup.gsc with one line added; it writes HTTPTEST lines to
games_mp.log, which are checked here. While a slow request is in progress the
server must keep answering queries, and after a map change the old map's
requests and connections must be dropped. Exits with 0 when every check passes.

Function Documentation

◆ main()

http_test.main ( )

◆ make_certs()

http_test.make_certs ( folder)
A CA (RSA) and two server certificates it signs: ECDSA for HTTPS, RSA for WSS.

◆ start()

http_test.start ( server)

◆ tls_context()

http_test.tls_context ( folder,
name,
max_version = None )

◆ wait_line()

http_test.wait_line ( path,
pattern,
seconds )

◆ ws_frame()

http_test.ws_frame ( opcode,
payload,
fin = True )

Variable Documentation

◆ CALLBACKS

str http_test.CALLBACKS = 'maps/mp/gametypes/_callbacksetup.gsc'

◆ ERROR_CALLBACK

str http_test.ERROR_CALLBACK
Initial value:
1= r'''
2CodeCallback_Error(critical, function, message)
3{
4 logprint("HTTPERR " + message + "\n");
5}
6'''

◆ HOOK

str http_test.HOOK = 'thread maps\\mp\\gametypes\\_httptest::main();'

◆ MARKER

str http_test.MARKER = '[[level.callbackStartGameType]]();'

◆ MOD

str http_test.MOD = 'httptest'

◆ RAW_RESPONSES

dict http_test.RAW_RESPONSES
Initial value:
1= {
2 '/nulheader': b'HTTP/1.1 200 OK\r\nX-A\0b: 1\r\nX-A\0c: 2\r\nContent-Length: 2\r\n\r\nok',
3 '/ctlheader': b'HTTP/1.1 200 OK\r\nX\x01A: 1\r\nContent-Length: 2\r\n\r\nok',
4 '/manyheaders': b'HTTP/1.1 200 OK\r\n' + b''.join(b'X-H%d: %d\r\n' % (i, i) for i in range(150))
5 + b'Content-Length: 2\r\n\r\nok',
6 '/folded': b'HTTP/1.1 200 OK\r\nX-Test: one\r\n two\r\nContent-Length: 2\r\n\r\nok',
7 '/hexlength': b'HTTP/1.1 200 OK\r\nContent-Length: 0x2\r\n\r\nok',
8 '/samelength': b'HTTP/1.1 200 OK\r\nContent-Length: 2\r\nContent-Length: 2\r\n\r\nok',
9 '/twolengths': b'HTTP/1.1 200 OK\r\nContent-Length: 2\r\nContent-Length: 1\r\n\r\nok',
10 '/continue': b'HTTP/1.1 100 Continue\r\n\r\n' * 3 + b'HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nok',
11 '/endless': b'HTTP/1.1 100 Continue\r\n\r\n' * 20 + b'HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nok',
12}

◆ ROOT

http_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ STATE

http_test.STATE = State()

◆ TEST_SCRIPT

str http_test.TEST_SCRIPT

◆ WS_GUID

str http_test.WS_GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'