MCPcopy Index your code
hub / github.com/keploy/keploy / CompareHTTPStream

Function CompareHTTPStream

pkg/util.go:945–960  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
945func 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
962func ComputeStreamingTimeoutSeconds(tc *models.TestCase, defaultSeconds uint64) uint64 {
963 baseTimeout := defaultSeconds

Calls 5

compareSSEStreamFunction · 0.85
compareNDJSONStreamFunction · 0.85
compareMultipartStreamFunction · 0.85
comparePlainTextStreamFunction · 0.85
compareBinaryStreamFunction · 0.85