@api-client/core 0.18.12 → 0.18.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/browser.d.ts +0 -3
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +0 -3
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +2 -5
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -5
- package/build/src/index.js.map +1 -1
- package/build/src/lib/logging/DefaultLogger.d.ts +14 -0
- package/build/src/lib/logging/DefaultLogger.d.ts.map +1 -1
- package/build/src/lib/logging/DefaultLogger.js +27 -0
- package/build/src/lib/logging/DefaultLogger.js.map +1 -1
- package/build/src/lib/logging/index.d.ts +4 -0
- package/build/src/lib/logging/index.d.ts.map +1 -0
- package/build/src/lib/logging/index.js +10 -0
- package/build/src/lib/logging/index.js.map +1 -0
- package/build/src/models/ClientCertificate.d.ts +1 -1
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/RequestConfig.d.ts +1 -1
- package/build/src/models/RequestConfig.js.map +1 -1
- package/build/src/models/SerializableError.d.ts +1 -1
- package/build/src/models/SerializableError.d.ts.map +1 -1
- package/build/src/models/SerializableError.js.map +1 -1
- package/build/src/proxy/RequestProxy.d.ts.map +1 -1
- package/build/src/proxy/RequestProxy.js +2 -2
- package/build/src/proxy/RequestProxy.js.map +1 -1
- package/build/src/runtime/http-engine/CoreEngine.d.ts +218 -139
- package/build/src/runtime/http-engine/CoreEngine.d.ts.map +1 -1
- package/build/src/runtime/http-engine/CoreEngine.js +716 -870
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
- package/build/src/runtime/http-engine/PayloadSupport.d.ts.map +1 -1
- package/build/src/runtime/http-engine/PayloadSupport.js +2 -1
- package/build/src/runtime/http-engine/PayloadSupport.js.map +1 -1
- package/build/src/runtime/http-engine/auth/AuthManager.d.ts +73 -0
- package/build/src/runtime/http-engine/auth/AuthManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/auth/AuthManager.js +186 -0
- package/build/src/runtime/http-engine/auth/AuthManager.js.map +1 -0
- package/build/src/runtime/http-engine/auth/index.d.ts +2 -0
- package/build/src/runtime/http-engine/auth/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/auth/index.js +2 -0
- package/build/src/runtime/http-engine/auth/index.js.map +1 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts +11 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.js +76 -0
- package/build/src/runtime/http-engine/certificates/CertificateManager.js.map +1 -0
- package/build/src/runtime/http-engine/certificates/index.d.ts +2 -0
- package/build/src/runtime/http-engine/certificates/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/certificates/index.js +2 -0
- package/build/src/runtime/http-engine/certificates/index.js.map +1 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.d.ts +25 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.js +89 -0
- package/build/src/runtime/http-engine/compression/CompressionManager.js.map +1 -0
- package/build/src/runtime/http-engine/compression/index.d.ts +2 -0
- package/build/src/runtime/http-engine/compression/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/compression/index.js +2 -0
- package/build/src/runtime/http-engine/compression/index.js.map +1 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts +57 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.js +78 -0
- package/build/src/runtime/http-engine/connections/ConnectionManager.js.map +1 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts +70 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.js +184 -0
- package/build/src/runtime/http-engine/connections/DigestAuthHandler.js.map +1 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.d.ts +22 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.js +105 -0
- package/build/src/runtime/http-engine/connections/DirectConnection.js.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts +60 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js +138 -0
- package/build/src/runtime/http-engine/connections/ProxyAuthHandler.js.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts +14 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.js +47 -0
- package/build/src/runtime/http-engine/connections/ProxyConnection.js.map +1 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts +13 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.js +175 -0
- package/build/src/runtime/http-engine/connections/TunnelConnection.js.map +1 -0
- package/build/src/runtime/http-engine/connections/index.d.ts +7 -0
- package/build/src/runtime/http-engine/connections/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/connections/index.js +7 -0
- package/build/src/runtime/http-engine/connections/index.js.map +1 -0
- package/build/src/runtime/http-engine/constants.d.ts +69 -0
- package/build/src/runtime/http-engine/constants.d.ts.map +1 -0
- package/build/src/runtime/http-engine/constants.js +90 -0
- package/build/src/runtime/http-engine/constants.js.map +1 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts +5 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.js +20 -0
- package/build/src/runtime/http-engine/cookies/CookieProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/cookies/index.d.ts +2 -0
- package/build/src/runtime/http-engine/cookies/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/cookies/index.js +2 -0
- package/build/src/runtime/http-engine/cookies/index.js.map +1 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts +156 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.d.ts.map +1 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.js +227 -0
- package/build/src/runtime/http-engine/errors/HttpEngineErrors.js.map +1 -0
- package/build/src/runtime/http-engine/errors/index.d.ts +2 -0
- package/build/src/runtime/http-engine/errors/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/errors/index.js +2 -0
- package/build/src/runtime/http-engine/errors/index.js.map +1 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.d.ts +66 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.d.ts.map +1 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.js +161 -0
- package/build/src/runtime/http-engine/message/MessageBuilder.js.map +1 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.d.ts +27 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.js +51 -0
- package/build/src/runtime/http-engine/message/MessageProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/message/index.d.ts +3 -0
- package/build/src/runtime/http-engine/message/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/message/index.js +3 -0
- package/build/src/runtime/http-engine/message/index.js.map +1 -0
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts +2 -8
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.d.ts.map +1 -1
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.js +11 -5
- package/build/src/runtime/http-engine/ntlm/NtlmAuth.js.map +1 -1
- package/build/src/runtime/http-engine/ntlm/NtlmMessage.js +6 -6
- package/build/src/runtime/http-engine/ntlm/NtlmMessage.js.map +1 -1
- package/build/src/runtime/http-engine/parsers/BodyParser.d.ts +39 -0
- package/build/src/runtime/http-engine/parsers/BodyParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/BodyParser.js +145 -0
- package/build/src/runtime/http-engine/parsers/BodyParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts +29 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.js +88 -0
- package/build/src/runtime/http-engine/parsers/HeadersParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts +91 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.js +236 -0
- package/build/src/runtime/http-engine/parsers/HttpResponseParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.d.ts +20 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.js +51 -0
- package/build/src/runtime/http-engine/parsers/StatusParser.js.map +1 -0
- package/build/src/runtime/http-engine/parsers/index.d.ts +5 -0
- package/build/src/runtime/http-engine/parsers/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/parsers/index.js +5 -0
- package/build/src/runtime/http-engine/parsers/index.js.map +1 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts +22 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.js +25 -0
- package/build/src/runtime/http-engine/response/ResponseProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/response/index.d.ts +2 -0
- package/build/src/runtime/http-engine/response/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/response/index.js +2 -0
- package/build/src/runtime/http-engine/response/index.js.map +1 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts +7 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js +40 -0
- package/build/src/runtime/http-engine/statistics/StatisticsProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/statistics/index.d.ts +2 -0
- package/build/src/runtime/http-engine/statistics/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/statistics/index.js +2 -0
- package/build/src/runtime/http-engine/statistics/index.js.map +1 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.d.ts +24 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.d.ts.map +1 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.js +50 -0
- package/build/src/runtime/http-engine/url/UrlProcessor.js.map +1 -0
- package/build/src/runtime/http-engine/url/index.d.ts +2 -0
- package/build/src/runtime/http-engine/url/index.d.ts.map +1 -0
- package/build/src/runtime/http-engine/url/index.js +2 -0
- package/build/src/runtime/http-engine/url/index.js.map +1 -0
- package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +3 -3
- package/build/src/runtime/http-runner/HttpRequestRunner.d.ts.map +1 -1
- package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
- package/build/src/runtime/node/InteropInterfaces.d.ts +3 -3
- package/build/src/runtime/node/InteropInterfaces.d.ts.map +1 -1
- package/build/src/runtime/node/InteropInterfaces.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +2 -2
- package/build/src/runtime/node/ProjectRequestRunner.d.ts.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts.map +1 -1
- package/build/src/runtime/node/ProjectRunner.js +2 -2
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/package.json +2 -2
- package/src/lib/logging/DefaultLogger.ts +32 -0
- package/src/models/ClientCertificate.ts +1 -1
- package/src/models/RequestConfig.ts +1 -1
- package/src/models/SerializableError.ts +1 -1
- package/src/proxy/RequestProxy.ts +2 -2
- package/src/runtime/http-engine/CoreEngine.ts +858 -893
- package/src/runtime/http-engine/PayloadSupport.ts +2 -1
- package/src/runtime/http-engine/auth/AuthManager.ts +242 -0
- package/src/runtime/http-engine/certificates/CertificateManager.ts +74 -0
- package/src/runtime/http-engine/compression/CompressionManager.ts +99 -0
- package/src/runtime/http-engine/connections/ConnectionManager.ts +123 -0
- package/src/runtime/http-engine/connections/DigestAuthHandler.ts +238 -0
- package/src/runtime/http-engine/connections/DirectConnection.ts +134 -0
- package/src/runtime/http-engine/connections/ProxyAuthHandler.ts +179 -0
- package/src/runtime/http-engine/connections/ProxyConnection.ts +55 -0
- package/src/runtime/http-engine/connections/TunnelConnection.ts +192 -0
- package/src/runtime/http-engine/constants.ts +103 -0
- package/src/runtime/http-engine/cookies/CookieProcessor.ts +25 -0
- package/src/runtime/http-engine/errors/HttpEngineErrors.ts +319 -0
- package/src/runtime/http-engine/message/MessageBuilder.ts +201 -0
- package/src/runtime/http-engine/message/MessageProcessor.ts +73 -0
- package/src/runtime/http-engine/ntlm/NtlmAuth.ts +16 -13
- package/src/runtime/http-engine/ntlm/NtlmMessage.ts +6 -6
- package/src/runtime/http-engine/parsers/BodyParser.ts +171 -0
- package/src/runtime/http-engine/parsers/HeadersParser.ts +103 -0
- package/src/runtime/http-engine/parsers/HttpResponseParser.ts +280 -0
- package/src/runtime/http-engine/parsers/StatusParser.ts +69 -0
- package/src/runtime/http-engine/response/ResponseProcessor.ts +46 -0
- package/src/runtime/http-engine/statistics/StatisticsProcessor.ts +52 -0
- package/src/runtime/http-engine/url/UrlProcessor.ts +55 -0
- package/src/runtime/http-runner/HttpRequestRunner.ts +3 -3
- package/src/runtime/node/InteropInterfaces.ts +3 -3
- package/src/runtime/node/ProjectRequestRunner.ts +2 -2
- package/src/runtime/node/ProjectRunner.ts +2 -2
- package/tests/servers/ProxyServer.ts +32 -19
- package/tests/servers/express-routes/ApiEndpoint.ts +24 -0
- package/tests/servers/express-routes/BasicAuthRoute.ts +36 -0
- package/tests/servers/express-routes/BearerAuthRoute.ts +35 -0
- package/tests/servers/express-routes/NTLMRoute.ts +2 -3
- package/tests/servers/express-routes/PostApi.ts +15 -2
- package/tests/servers/express-routes/RedirectsApi.ts +12 -1
- package/tests/servers/express-routes/ResponsesApi.ts +1 -1
- package/tests/servers/express-routes/StreamApi.ts +19 -0
- package/tests/servers/oauth2mock/ServerMock.js +1 -1
- package/tests/unit/runtime/http-engine/HttpResponseParser.spec.ts +337 -0
- package/tests/unit/runtime/http-engine/abort.spec.ts +4 -5
- package/tests/unit/runtime/http-engine/auth.spec.ts +7 -58
- package/tests/unit/runtime/http-engine/certificates/CertificateManager.spec.ts +482 -0
- package/tests/unit/runtime/http-engine/certificates.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/compression/CompressionManager.spec.ts +498 -0
- package/tests/unit/runtime/http-engine/compression.spec.ts +3 -72
- package/tests/unit/runtime/http-engine/connections/ConnectionManager.spec.ts +379 -0
- package/tests/unit/runtime/http-engine/connections/DigestAuthHandler.spec.ts +164 -0
- package/tests/unit/runtime/http-engine/core_engine.spec.ts +561 -0
- package/tests/unit/runtime/http-engine/engine_statuses.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/events.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/headers.spec.ts +2 -88
- package/tests/unit/runtime/http-engine/hosts.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/http-get.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/http-post.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/logger.spec.ts +0 -8
- package/tests/unit/runtime/http-engine/message.spec.ts +2 -194
- package/tests/unit/runtime/http-engine/params.spec.ts +4 -4
- package/tests/unit/runtime/http-engine/proxy.spec.ts +15 -14
- package/tests/unit/runtime/http-engine/redirects.spec.ts +2 -2
- package/tests/unit/runtime/http-engine/responses.spec.ts +170 -277
- package/tests/unit/runtime/http-engine/timeout.spec.ts +3 -3
- package/tests/unit/runtime/http-engine/timings.spec.ts +2 -2
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +25 -28
- package/tests/unit/runtime/runners/project_runner.spec.ts +2 -2
- package/tests/unit/runtime/runners/request_runner.spec.ts +2 -2
- package/build/src/runtime/http-engine/HttpEngine.d.ts +0 -311
- package/build/src/runtime/http-engine/HttpEngine.d.ts.map +0 -1
- package/build/src/runtime/http-engine/HttpEngine.js +0 -802
- package/build/src/runtime/http-engine/HttpEngine.js.map +0 -1
- package/src/runtime/http-engine/HttpEngine.ts +0 -952
- package/tests/unit/runtime/http-engine/connecting.spec.ts +0 -140
|
@@ -2,16 +2,15 @@ import { test } from '@japa/runner'
|
|
|
2
2
|
import {
|
|
3
3
|
IResponse,
|
|
4
4
|
Response,
|
|
5
|
-
|
|
5
|
+
createLogger,
|
|
6
6
|
CoreEngine,
|
|
7
7
|
IHttpRequest,
|
|
8
8
|
HttpEngineOptions,
|
|
9
9
|
Headers,
|
|
10
10
|
IRequestsSize,
|
|
11
|
-
RequestState,
|
|
12
11
|
} from '../../../../src/index.js'
|
|
13
12
|
|
|
14
|
-
const logger =
|
|
13
|
+
const logger = createLogger()
|
|
15
14
|
|
|
16
15
|
test.group('Request size', () => {
|
|
17
16
|
test('has the request size value', async ({ assert, httpConfig }) => {
|
|
@@ -79,112 +78,6 @@ test.group('Responses test', () => {
|
|
|
79
78
|
})
|
|
80
79
|
})
|
|
81
80
|
|
|
82
|
-
test.group('Data buffer responses', (group) => {
|
|
83
|
-
// https://github.com/advanced-rest-client/arc-electron/issues/75#issuecomment-399204512
|
|
84
|
-
const parts = [
|
|
85
|
-
Buffer.from([
|
|
86
|
-
72, 84, 84, 80, 47, 49, 46, 48, 32, 50, 48, 48, 32, 79, 75, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121,
|
|
87
|
-
112, 101, 58, 32, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 106, 115, 111, 110, 13, 10, 67, 111,
|
|
88
|
-
110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32, 49, 49, 52, 13, 10,
|
|
89
|
-
]),
|
|
90
|
-
Buffer.from([
|
|
91
|
-
83, 101, 114, 118, 101, 114, 58, 32, 87, 101, 114, 107, 122, 101, 117, 103, 47, 48, 46, 49, 52, 46, 49, 32, 80,
|
|
92
|
-
121, 116, 104, 111, 110, 47, 50, 46, 55, 46, 49, 52, 13, 10, 68, 97, 116, 101, 58, 32, 84, 104, 117, 44, 32, 50,
|
|
93
|
-
49, 32, 74, 117, 110, 32, 50, 48, 49, 56, 32, 49, 56, 58, 51, 48, 58, 53, 49, 32, 71, 77, 84, 13, 10, 13, 10, 123,
|
|
94
|
-
34, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 95, 105, 100, 34, 58, 32, 50, 52, 49, 56, 54, 44, 32, 34,
|
|
95
|
-
117, 115, 101, 114, 95, 105, 100, 34, 58, 32, 53, 57, 44, 32, 34, 112, 114, 111, 100, 117, 99, 116, 95, 105, 100,
|
|
96
|
-
34, 58, 32, 51, 50, 54, 57, 44, 32, 34, 112, 114, 105, 99, 101, 34, 58, 32, 50, 46, 48, 44, 32, 34, 115, 105, 100,
|
|
97
|
-
101, 34, 58, 32, 34, 83, 101, 108, 108, 34, 44, 32, 34, 105, 100, 34, 58, 32, 50, 44, 32, 34, 113, 117, 97, 110,
|
|
98
|
-
116, 105, 116, 121, 34, 58, 32, 48, 125, 10,
|
|
99
|
-
]),
|
|
100
|
-
// After processing status line
|
|
101
|
-
Buffer.from([
|
|
102
|
-
67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111,
|
|
103
|
-
110, 47, 106, 115, 111, 110, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32,
|
|
104
|
-
49, 49, 52, 13, 10,
|
|
105
|
-
]),
|
|
106
|
-
]
|
|
107
|
-
const headersMap: Record<string, string> = {
|
|
108
|
-
'Content-Type': 'application/json',
|
|
109
|
-
'Content-Length': '114',
|
|
110
|
-
'Server': 'Werkzeug/0.14.1 Python/2.7.14',
|
|
111
|
-
'Date': 'Thu, 21 Jun 2018 18:30:51 GMT',
|
|
112
|
-
}
|
|
113
|
-
let request: IHttpRequest
|
|
114
|
-
let opts: HttpEngineOptions
|
|
115
|
-
|
|
116
|
-
let engine: CoreEngine
|
|
117
|
-
group.each.setup((ctx) => {
|
|
118
|
-
request = {
|
|
119
|
-
url: `http://localhost:${ctx.context.httpConfig.httpPort}/v1/stream`,
|
|
120
|
-
method: 'GET',
|
|
121
|
-
headers: 'Host: test.com\nContent-Length: 0',
|
|
122
|
-
payload: 'abc',
|
|
123
|
-
}
|
|
124
|
-
opts = {
|
|
125
|
-
timeout: 50000,
|
|
126
|
-
followRedirects: false,
|
|
127
|
-
logger,
|
|
128
|
-
}
|
|
129
|
-
engine = new CoreEngine(request, opts)
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
test('returns data from the _processStatus()', ({ assert }) => {
|
|
133
|
-
const result = engine._processStatus(parts[0]) as Buffer
|
|
134
|
-
assert.equal(result.compare(parts[2]), 0)
|
|
135
|
-
}).tags(['@http-engine', '@response'])
|
|
136
|
-
|
|
137
|
-
test('reads the status line', ({ assert }) => {
|
|
138
|
-
engine._processSocketMessage(parts[0])
|
|
139
|
-
const cr = engine.currentResponse as Response
|
|
140
|
-
assert.equal(cr.status, 200, 'Status code is set')
|
|
141
|
-
assert.equal(cr.statusText, 'OK', 'Status message is set')
|
|
142
|
-
}).tags(['@http-engine', '@response'])
|
|
143
|
-
|
|
144
|
-
test('puts headers from part #1 after processing status to temp variable', ({ assert }) => {
|
|
145
|
-
engine._processHeaders(parts[2])
|
|
146
|
-
const headers = engine.rawHeaders as Buffer
|
|
147
|
-
assert.equal(headers.compare(parts[2]), 0)
|
|
148
|
-
}).tags(['@http-engine', '@response'])
|
|
149
|
-
|
|
150
|
-
test('sets the state to HEADERS after first part', ({ assert }) => {
|
|
151
|
-
engine._processSocketMessage(parts[0])
|
|
152
|
-
assert.equal(engine.state, RequestState.Headers)
|
|
153
|
-
}).tags(['@http-engine', '@response'])
|
|
154
|
-
|
|
155
|
-
function processMessages(): void {
|
|
156
|
-
engine._processSocketMessage(parts[0])
|
|
157
|
-
engine._processSocketMessage(parts[1])
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
test('processes both messages', ({ assert }) => {
|
|
161
|
-
processMessages()
|
|
162
|
-
assert.equal(engine.state, RequestState.Done)
|
|
163
|
-
}).tags(['@http-engine', '@response'])
|
|
164
|
-
|
|
165
|
-
test('sets the status', ({ assert }) => {
|
|
166
|
-
processMessages()
|
|
167
|
-
const cr = engine.currentResponse as Response
|
|
168
|
-
assert.equal(cr.status, 200, 'Status code is set')
|
|
169
|
-
assert.equal(cr.statusText, 'OK', 'Status message is set')
|
|
170
|
-
}).tags(['@http-engine', '@response'])
|
|
171
|
-
|
|
172
|
-
test('sets the headers', ({ assert }) => {
|
|
173
|
-
processMessages()
|
|
174
|
-
const cr = engine.currentResponse as Response
|
|
175
|
-
assert.typeOf(cr.headers, 'string')
|
|
176
|
-
assert.typeOf(engine.currentHeaders, 'object')
|
|
177
|
-
engine.currentHeaders.forEach((value, name) => {
|
|
178
|
-
assert.equal(headersMap[name], value)
|
|
179
|
-
})
|
|
180
|
-
}).tags(['@http-engine', '@response'])
|
|
181
|
-
|
|
182
|
-
test('sets the body', ({ assert }) => {
|
|
183
|
-
processMessages()
|
|
184
|
-
assert.isTrue(engine._rawBody instanceof Buffer)
|
|
185
|
-
}).tags(['@http-engine', '@response'])
|
|
186
|
-
})
|
|
187
|
-
|
|
188
81
|
test.group('Chunked responses', (group) => {
|
|
189
82
|
let request: IHttpRequest
|
|
190
83
|
let opts: HttpEngineOptions
|
|
@@ -217,171 +110,171 @@ test.group('Chunked responses', (group) => {
|
|
|
217
110
|
}).tags(['@http-engine', '@response', '@chunked'])
|
|
218
111
|
})
|
|
219
112
|
|
|
220
|
-
test.group('readChunkSize()', (group) => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
test.group('_processBodyChunked()', (group) => {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
test.group('_processBody()', (group) => {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
})
|
|
113
|
+
// test.group('readChunkSize()', (group) => {
|
|
114
|
+
// let engine: CoreEngine
|
|
115
|
+
// let request: IHttpRequest
|
|
116
|
+
// let opts: HttpEngineOptions
|
|
117
|
+
|
|
118
|
+
// group.each.setup((ctx) => {
|
|
119
|
+
// request = {
|
|
120
|
+
// url: `http://localhost:${ctx.context.httpConfig.httpPort}/v1/stream`,
|
|
121
|
+
// method: 'GET',
|
|
122
|
+
// headers: 'Host: test.com\nContent-Length: 0',
|
|
123
|
+
// payload: 'abc',
|
|
124
|
+
// }
|
|
125
|
+
// opts = {
|
|
126
|
+
// timeout: 50000,
|
|
127
|
+
// followRedirects: false,
|
|
128
|
+
// logger,
|
|
129
|
+
// }
|
|
130
|
+
// engine = new CoreEngine(request, opts)
|
|
131
|
+
// })
|
|
132
|
+
|
|
133
|
+
// test('returns the the same array when new line is not found', ({ assert }) => {
|
|
134
|
+
// const b = Buffer.from('test')
|
|
135
|
+
// const result = engine.readChunkSize(b)
|
|
136
|
+
// assert.isTrue(b === result)
|
|
137
|
+
// }).tags(['@http-engine', '@response', '@chunked'])
|
|
138
|
+
|
|
139
|
+
// test('does not set chunkSize property', ({ assert }) => {
|
|
140
|
+
// const b = Buffer.from('test')
|
|
141
|
+
// engine.readChunkSize(b)
|
|
142
|
+
// assert.isUndefined(engine.responseInfo.chunkSize)
|
|
143
|
+
// }).tags(['@http-engine', '@response', '@chunked'])
|
|
144
|
+
|
|
145
|
+
// test('parses chunk size', ({ assert }) => {
|
|
146
|
+
// let chunk = Number(128).toString(16)
|
|
147
|
+
// chunk += '\r\ntest'
|
|
148
|
+
// const b = Buffer.from(chunk)
|
|
149
|
+
// engine.readChunkSize(b)
|
|
150
|
+
// assert.equal(engine.responseInfo.chunkSize, 128)
|
|
151
|
+
// }).tags(['@http-engine', '@response', '@chunked'])
|
|
152
|
+
|
|
153
|
+
// test('truncates the buffer', ({ assert }) => {
|
|
154
|
+
// let chunk = Number(128).toString(16)
|
|
155
|
+
// chunk += '\r\ntest'
|
|
156
|
+
// const b = Buffer.from(chunk)
|
|
157
|
+
// const result = engine.readChunkSize(b) as Buffer
|
|
158
|
+
// assert.equal(result.toString(), 'test')
|
|
159
|
+
// }).tags(['@http-engine', '@response', '@chunked'])
|
|
160
|
+
// })
|
|
161
|
+
|
|
162
|
+
// test.group('_processBodyChunked()', (group) => {
|
|
163
|
+
// let engine: CoreEngine
|
|
164
|
+
// let request: IHttpRequest
|
|
165
|
+
// let opts: HttpEngineOptions
|
|
166
|
+
|
|
167
|
+
// group.each.setup((ctx) => {
|
|
168
|
+
// request = {
|
|
169
|
+
// url: `http://localhost:${ctx.context.httpConfig.httpPort}/v1/stream`,
|
|
170
|
+
// method: 'GET',
|
|
171
|
+
// headers: 'Host: test.com\nContent-Length: 0',
|
|
172
|
+
// payload: 'abc',
|
|
173
|
+
// }
|
|
174
|
+
// opts = {
|
|
175
|
+
// timeout: 50000,
|
|
176
|
+
// followRedirects: false,
|
|
177
|
+
// logger,
|
|
178
|
+
// }
|
|
179
|
+
// engine = new CoreEngine(request, opts)
|
|
180
|
+
// engine._reportResponse = (): void => {}
|
|
181
|
+
// })
|
|
182
|
+
|
|
183
|
+
// test('reads body chunk', ({ assert }) => {
|
|
184
|
+
// let chunk = Number(4).toString(16)
|
|
185
|
+
// chunk += '\r\ntest\r\n0\r\n'
|
|
186
|
+
// const b = Buffer.from(chunk)
|
|
187
|
+
// engine._processBodyChunked(b)
|
|
188
|
+
// assert.equal(engine.responseInfo.chunkSize, 0)
|
|
189
|
+
// assert.equal((engine._rawBody as Buffer).toString(), 'test')
|
|
190
|
+
// }).tags(['@http-engine', '@response', '@chunked'])
|
|
191
|
+
|
|
192
|
+
// test('Reads multi chunks', ({ assert }) => {
|
|
193
|
+
// let chunk = Number(6).toString(16)
|
|
194
|
+
// chunk += '\r\ntest\r\n\r\n'
|
|
195
|
+
// chunk += Number(8).toString(16)
|
|
196
|
+
// chunk += '\r\ntest1234\r\n'
|
|
197
|
+
// chunk += '0\r\n'
|
|
198
|
+
// const b = Buffer.from(chunk)
|
|
199
|
+
// engine._processBodyChunked(b)
|
|
200
|
+
// assert.equal(engine.responseInfo.chunkSize, 0)
|
|
201
|
+
// assert.equal((engine._rawBody as Buffer).toString(), 'test\r\ntest1234')
|
|
202
|
+
// }).tags(['@http-engine', '@response', '@chunked'])
|
|
203
|
+
|
|
204
|
+
// test('Reads multi chunks with partial buffer', ({ assert }) => {
|
|
205
|
+
// let chunk = Number(6).toString(16)
|
|
206
|
+
// chunk += '\r\nte'
|
|
207
|
+
// engine._processBodyChunked(Buffer.from(chunk))
|
|
208
|
+
// chunk = 'st\r\n\r\n'
|
|
209
|
+
// engine._processBodyChunked(Buffer.from(chunk))
|
|
210
|
+
// chunk = Number(8).toString(16)
|
|
211
|
+
// chunk += '\r\ntest'
|
|
212
|
+
// engine._processBodyChunked(Buffer.from(chunk))
|
|
213
|
+
// chunk = '1234\r\n0\r\n'
|
|
214
|
+
// engine._processBodyChunked(Buffer.from(chunk))
|
|
215
|
+
// assert.equal(engine.responseInfo.chunkSize, 0)
|
|
216
|
+
// assert.equal((engine._rawBody as Buffer).toString(), 'test\r\ntest1234')
|
|
217
|
+
// }).tags(['@http-engine', '@response', '@chunked'])
|
|
218
|
+
// })
|
|
219
|
+
|
|
220
|
+
// test.group('_processBody()', (group) => {
|
|
221
|
+
// const testData = Buffer.from('abcdefghijklmn')
|
|
222
|
+
// const testLength = testData.length
|
|
223
|
+
// let engine: CoreEngine
|
|
224
|
+
// let request: IHttpRequest
|
|
225
|
+
// let opts: HttpEngineOptions
|
|
226
|
+
|
|
227
|
+
// group.each.setup((ctx) => {
|
|
228
|
+
// request = {
|
|
229
|
+
// url: `http://localhost:${ctx.context.httpConfig.httpPort}/v1/stream`,
|
|
230
|
+
// method: 'GET',
|
|
231
|
+
// headers: 'Host: test.com\nContent-Length: 0',
|
|
232
|
+
// payload: 'abc',
|
|
233
|
+
// }
|
|
234
|
+
// opts = {
|
|
235
|
+
// timeout: 50000,
|
|
236
|
+
// followRedirects: false,
|
|
237
|
+
// logger,
|
|
238
|
+
// }
|
|
239
|
+
// engine = new CoreEngine(request, opts)
|
|
240
|
+
// engine._reportResponse = (): void => {}
|
|
241
|
+
// })
|
|
242
|
+
|
|
243
|
+
// test('sets the responseInfo.body property', ({ assert }) => {
|
|
244
|
+
// engine.responseInfo.contentLength = testLength + 1
|
|
245
|
+
// engine.responseInfo.chunked = false
|
|
246
|
+
// engine._processBody(testData)
|
|
247
|
+
// assert.equal((engine.responseInfo.body as Buffer).toString(), testData.toString())
|
|
248
|
+
// }).tags(['@http-engine', '@response'])
|
|
249
|
+
|
|
250
|
+
// test('does not call _reportResponse when length is higher than data', ({ assert }) => {
|
|
251
|
+
// engine.responseInfo.contentLength = testLength + 1
|
|
252
|
+
// let called = false
|
|
253
|
+
// engine._reportResponse = (): void => {
|
|
254
|
+
// called = true
|
|
255
|
+
// }
|
|
256
|
+
// engine._processBody(testData)
|
|
257
|
+
// assert.isFalse(called)
|
|
258
|
+
// }).tags(['@http-engine', '@response'])
|
|
259
|
+
|
|
260
|
+
// test('reports response when the data is read as whole on one socket buffer', ({ assert }) => {
|
|
261
|
+
// engine.responseInfo.contentLength = testLength
|
|
262
|
+
// let called = false
|
|
263
|
+
// engine._reportResponse = (): void => {
|
|
264
|
+
// called = true
|
|
265
|
+
// }
|
|
266
|
+
// engine._processBody(testData)
|
|
267
|
+
// assert.isTrue(called, '_reportResponse was called')
|
|
268
|
+
// }).tags(['@http-engine', '@response'])
|
|
269
|
+
|
|
270
|
+
// test('reports response after more calls', ({ assert }) => {
|
|
271
|
+
// engine.responseInfo.contentLength = testLength
|
|
272
|
+
// let called = false
|
|
273
|
+
// engine._reportResponse = (): void => {
|
|
274
|
+
// called = true
|
|
275
|
+
// }
|
|
276
|
+
// engine._processBody(Buffer.from('abcdef'))
|
|
277
|
+
// engine._processBody(Buffer.from('ghijklmn'))
|
|
278
|
+
// assert.isTrue(called, '_reportResponse was called')
|
|
279
|
+
// }).tags(['@http-engine', '@response'])
|
|
280
|
+
// })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test } from '@japa/runner'
|
|
2
2
|
import sinon from 'sinon'
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
createLogger,
|
|
5
5
|
CoreEngine,
|
|
6
6
|
IHttpRequest,
|
|
7
7
|
HttpEngineOptions,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ISerializedError,
|
|
10
10
|
} from '../../../../src/index.js'
|
|
11
11
|
|
|
12
|
-
const logger =
|
|
12
|
+
const logger = createLogger()
|
|
13
13
|
|
|
14
14
|
test.group('Timeout test', (group) => {
|
|
15
15
|
let opts: HttpEngineOptions
|
|
@@ -34,6 +34,6 @@ test.group('Timeout test', (group) => {
|
|
|
34
34
|
assert.isFalse(spy.called, 'loadend was not called')
|
|
35
35
|
const response = info.response as IErrorResponse
|
|
36
36
|
assert.equal(response.status, 0, 'status is 0')
|
|
37
|
-
assert.equal((response.error as ISerializedError).message, 'Connection timeout
|
|
37
|
+
assert.equal((response.error as ISerializedError).message, 'Connection timeout after 60ms')
|
|
38
38
|
})
|
|
39
39
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test } from '@japa/runner'
|
|
2
|
-
import { IResponse,
|
|
2
|
+
import { IResponse, createLogger, CoreEngine, IRequestTime } from '../../../../src/index.js'
|
|
3
3
|
|
|
4
|
-
const logger =
|
|
4
|
+
const logger = createLogger()
|
|
5
5
|
|
|
6
6
|
test.group('Timings tests', () => {
|
|
7
7
|
test('has the stats object', async ({ assert, httpConfig }) => {
|