update
This commit is contained in:
@ -53,7 +53,7 @@ tap.test('should create ACME challenge route with high ports', async (tools) =>
|
||||
expect(challengeRoute).toBeDefined();
|
||||
expect(challengeRoute.match.path).toEqual('/.well-known/acme-challenge/*');
|
||||
expect(challengeRoute.match.ports).toEqual(18080);
|
||||
expect(challengeRoute.action.type).toEqual('static');
|
||||
expect(challengeRoute.action.type).toEqual('socket-handler');
|
||||
expect(challengeRoute.priority).toEqual(1000);
|
||||
|
||||
await proxy.stop();
|
||||
@ -74,15 +74,30 @@ tap.test('should handle HTTP request parsing correctly', async (tools) => {
|
||||
path: '/test/*'
|
||||
},
|
||||
action: {
|
||||
type: 'static' as const,
|
||||
handler: async (context) => {
|
||||
type: 'socket-handler' as const,
|
||||
socketHandler: (socket, context) => {
|
||||
handlerCalled = true;
|
||||
receivedContext = context;
|
||||
return {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
body: 'OK'
|
||||
};
|
||||
|
||||
// Parse HTTP request from socket
|
||||
socket.once('data', (data) => {
|
||||
const request = data.toString();
|
||||
const lines = request.split('\r\n');
|
||||
const [method, path, protocol] = lines[0].split(' ');
|
||||
|
||||
// Send HTTP response
|
||||
const response = [
|
||||
'HTTP/1.1 200 OK',
|
||||
'Content-Type: text/plain',
|
||||
'Content-Length: 2',
|
||||
'Connection: close',
|
||||
'',
|
||||
'OK'
|
||||
].join('\r\n');
|
||||
|
||||
socket.write(response);
|
||||
socket.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user