CompareHTTPStream compares an expected HTTP response with a streaming response. It returns whether they match, the captured body content, mismatch details (if any), and any error.
(expectedResp models.HTTPResp, stream io.Reader, cfg HTTPStreamConfig, jsonNoiseKeys map[string]struct{}, logger *zap.Logger)
| 943 | // CompareHTTPStream compares an expected HTTP response with a streaming response. |
| 944 | // It returns whether they match, the captured body content, mismatch details (if any), and any error. |
| 945 | func CompareHTTPStream(expectedResp models.HTTPResp, stream io.Reader, cfg HTTPStreamConfig, jsonNoiseKeys map[string]struct{}, logger *zap.Logger) (bool, string, *StreamMismatchInfo, error) { |
| 946 | switch cfg.Mode { |
| 947 | case HTTPStreamModeSSE: |
| 948 | return compareSSEStream(expectedResp, stream, jsonNoiseKeys, logger) |
| 949 | case HTTPStreamModeNDJSON: |
| 950 | return compareNDJSONStream(expectedResp, stream, jsonNoiseKeys, logger) |
| 951 | case HTTPStreamModeMultipart: |
| 952 | return compareMultipartStream(expectedResp, stream, cfg.Boundary, jsonNoiseKeys, logger) |
| 953 | case HTTPStreamModePlainText: |
| 954 | return comparePlainTextStream(expectedResp, stream, logger) |
| 955 | case HTTPStreamModeBinary: |
| 956 | return compareBinaryStream(expectedResp, stream, logger) |
| 957 | default: |
| 958 | return false, "", nil, fmt.Errorf("unsupported HTTP stream mode: %s", cfg.Mode) |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | func ComputeStreamingTimeoutSeconds(tc *models.TestCase, defaultSeconds uint64) uint64 { |
| 963 | baseTimeout := defaultSeconds |