Bound authentication response recognition
This commit is contained in:
@@ -17,6 +17,8 @@ type authenticationProbe struct {
|
||||
client smokeHTTPGetter
|
||||
}
|
||||
|
||||
const maxAuthenticationResponseBytes = 1 << 20
|
||||
|
||||
type authenticationProbeOutcome struct {
|
||||
supported bool
|
||||
applicable *bool
|
||||
@@ -104,7 +106,17 @@ func (p authenticationProbe) runOpenRouterKey(
|
||||
outcome.failure = domain.ExecutionFailureMalformedResponse
|
||||
return outcome, nil
|
||||
}
|
||||
recognized, bodyErr := recognizedOpenRouterKeyResponse(response.Body)
|
||||
contents, bodyErr := io.ReadAll(io.LimitReader(response.Body, maxAuthenticationResponseBytes+1))
|
||||
if len(contents) > maxAuthenticationResponseBytes {
|
||||
outcome.reason = domain.SmokeTestReasonAuthenticationResponseLimitExceeded
|
||||
outcome.failure = domain.ExecutionFailureOther
|
||||
return outcome, nil
|
||||
}
|
||||
if bodyErr != nil {
|
||||
outcome.failure = httpProbeFailure(ctx, bodyErr)
|
||||
return outcome, nil
|
||||
}
|
||||
recognized, bodyErr := recognizedOpenRouterKeyResponse(bytes.NewReader(contents))
|
||||
if bodyErr != nil {
|
||||
outcome.failure = httpProbeFailure(ctx, bodyErr)
|
||||
return outcome, nil
|
||||
|
||||
Reference in New Issue
Block a user