MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / callResponseNormalizer

Method callResponseNormalizer

internal/pluginhost/adapters.go:1994–2018  ·  view source on GitHub ↗
(ctx context.Context, record capabilityRecord, method string, normalizer pluginapi.ResponseNormalizer, from, to sdktranslator.Format, model string, originalRequestRawJSON, requestRawJSON, body []byte, stream bool)

Source from the content-addressed store, hash-verified

1992}
1993
1994func (h *Host) callResponseNormalizer(ctx context.Context, record capabilityRecord, method string, normalizer pluginapi.ResponseNormalizer, from, to sdktranslator.Format, model string, originalRequestRawJSON, requestRawJSON, body []byte, stream bool) (out []byte, ok bool) {
1995 if h == nil || normalizer == nil || h.isPluginFused(record.id) || !h.recordCurrent(record) {
1996 return nil, false
1997 }
1998 defer func() {
1999 if recovered := recover(); recovered != nil {
2000 h.fusePlugin(record.id, method, recovered)
2001 out = nil
2002 ok = false
2003 }
2004 }()
2005 resp, errNormalizeResponse := normalizer.NormalizeResponse(ctx, pluginapi.ResponseTransformRequest{
2006 FromFormat: from.String(),
2007 ToFormat: to.String(),
2008 Model: model,
2009 Stream: stream,
2010 OriginalRequest: bytes.Clone(originalRequestRawJSON),
2011 TranslatedRequest: bytes.Clone(requestRawJSON),
2012 Body: bytes.Clone(body),
2013 })
2014 if errNormalizeResponse != nil || len(resp.Body) == 0 {
2015 return nil, false
2016 }
2017 return bytes.Clone(resp.Body), true
2018}
2019
2020func (h *Host) callResponseTranslator(ctx context.Context, record capabilityRecord, translator pluginapi.ResponseTranslator, from, to sdktranslator.Format, model string, originalRequestRawJSON, requestRawJSON, body []byte, stream bool) (out []byte, ok bool) {
2021 if h == nil || translator == nil || h.isPluginFused(record.id) || !h.recordCurrent(record) {

Callers 2

Calls 6

isPluginFusedMethod · 0.95
recordCurrentMethod · 0.95
fusePluginMethod · 0.95
NormalizeResponseMethod · 0.65
StringMethod · 0.45
CloneMethod · 0.45

Tested by

no test coverage detected