mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-11 17:50:01 -06:00
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)
53 lines
1.2 KiB
TypeScript
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)
|
|
}
|
|
}
|