Files
cypress/packages/proxy/lib/network-proxy.ts
Ryan Manuel 462ee04df9 feat: enable the protocol to retrieve response bodies from the network proxy (#27462)
Co-authored-by: Matt Schile <mschile@cypress.io>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
fix: do not correlate cached requests in the proxy (#27525)
2023-08-15 13:41:36 -05:00

53 lines
1.2 KiB
TypeScript

import { telemetry } from '@packages/telemetry'
import { Http, ServerCtx } from './http'
import type { BrowserPreRequest } from './types'
export class NetworkProxy {
http: Http
constructor (opts: ServerCtx) {
this.http = new Http(opts)
}
addPendingBrowserPreRequest (preRequest: BrowserPreRequest) {
this.http.addPendingBrowserPreRequest(preRequest)
}
removePendingBrowserPreRequest (requestId: string) {
this.http.removePendingBrowserPreRequest(requestId)
}
handleHttpRequest (req, res) {
const span = telemetry.startSpan({
name: 'network:proxy:handleHttpRequest',
opts: {
attributes: {
'network:proxy:url': req.proxiedUrl,
'network:proxy:contentType': req.get('content-type'),
},
},
isVerbose: true,
})
this.http.handleHttpRequest(req, res, span).finally(() => {
span?.end()
})
}
handleSourceMapRequest (req, res) {
this.http.handleSourceMapRequest(req, res)
}
setHttpBuffer (buffer) {
this.http.setBuffer(buffer)
}
reset () {
this.http.reset()
}
setProtocolManager (protocolManager) {
this.http.setProtocolManager(protocolManager)
}
}