You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug]: Using "request. Headers()" in "requestfinished" yields an error message. panic: interface conversion: interface {} is [] map [string] string, not [] interface {}
#453
Open
yby1988 opened this issue
Apr 30, 2024
· 0 comments
I need to obtain the request header after completing the request, and the main code is as follows:
“
Browser.chromeContext On ("requestfinished", fun (request playwright. Request){
Browser. responseListener (request)
})
Func (browser * BrowserStructure) responseListener (request playwright. Request){
Fmt Printf ("responseListener ->%+v \ n", request)
Go func(){
Var err error
ReqPackage:=""
Allheaders:=request Headers()
If err= Nil{
Return
}
For name, value:=range allheads{
ReqPackage+=name+":"+value+"\ r \ n"
}
PostData, err:=request PostData()
If err= Nil{
Return
}
ReqPackage+="\ r \ n"+postData
Fmt Printf (reqPackage)
}()
}
“
The output of the console is:
“
ResponseListener ->&{channelOwner: {RWMutex: {w: {state: 0 sema: 0} writer Sem: 0 reader Sem: 0 reader Count: {: {} v: 0} reader Wait: {: {} v: 0} event Emitter: {eventsMutex: {state: 0 sema: 0} events: map [] hasInit: false} objectType: Request guide: request@82f9101b4ce55eb6e7fc73fcce599f14 Channel: 0xc000302cd0 objects: map[ response@2202f08970ce71dcc1d71734c6e5ac50 : 0xc0003e13f0 route@eecedbb07715dfa4b8e6df74b0dfa309 : 0xc0004043c0] eventToSubscriptionMapping: map [] connection: 0xc00011c2c0 initializer: map [frame: 0xc000302aa0 headers: [map [name: Accept value: text/HTML, application/xHTML+XML, application/XML; q=0.9, image/avif, image/webp, image/png, /; q=0.8, application/signed exchange; v=b3; q=0.7] map [name: Upgrade Ensure Request s value: 1] map [name: User Agent value: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/123.0.6312.4 Safari/537.36] isNavigationRequest: true method: GET resourceType: document URL: http://192.168.3.170/ ]Parent: 0xc000314180 wasCollected: false} timing: 0xc000388230 provisionalHeaders: 0xc00034c400 allHeaders:redirectedFrom:redirectedTo:FailureText: fallbackOverrides: 0xc0003f9c50}
Panel: interface conversion: interface {} is [] map [string] string, not [] interface {}
Goroutine 48 [running]:
Github. com/playwright community/playwright go. newRawHeaders ({0x914140?, 0xc000062db0})
/Home/u/goprojects/pkg/mod/github. com/playwright community/ [email protected] /Network. go: 48+0x4b1
Github. com/playwright community/playwright go (* requestImpl) Headers (0xc00041e030?)
/Home/u/goprojects/pkg/mod/github. com/playwright community/ [email protected] /Request. go: 73+0x35c
Test/crawleModule (* BrowserStruct). responseListener. func1()
/Mnt/d/5. project/1. go/testV4.0/crowlModule/browser. go: 371+0x7d
Created by test/crawleModule (* BrowserStruct). responseListener in goroutine 8
/Mnt/d/5. project/1. go/testV4.0/crowlModule/browser. go: 352+0xe5
Exit status 2
“
Headers, allHeaders, and headerArrays all have this issue
The text was updated successfully, but these errors were encountered:
yby1988
changed the title
[Bug]: 130/10000 实时翻译 划译 Using "request. Headers()" in "requestfinished" yields an error message. panic: interface conversion: interface {} is [] map [string] string, not [] interface {}
[Bug]: Using "request. Headers()" in "requestfinished" yields an error message. panic: interface conversion: interface {} is [] map [string] string, not [] interface {}
Apr 30, 2024
I need to obtain the request header after completing the request, and the main code is as follows:
“
Browser.chromeContext On ("requestfinished", fun (request playwright. Request){
Browser. responseListener (request)
})
Func (browser * BrowserStructure) responseListener (request playwright. Request){
Fmt Printf ("responseListener ->%+v \ n", request)
Go func(){
Var err error
ReqPackage:=""
Allheaders:=request Headers()
If err= Nil{
Return
}
For name, value:=range allheads{
ReqPackage+=name+":"+value+"\ r \ n"
}
PostData, err:=request PostData()
If err= Nil{
Return
}
ReqPackage+="\ r \ n"+postData
Fmt Printf (reqPackage)
}()
}
“
The output of the console is:
“
ResponseListener ->&{channelOwner: {RWMutex: {w: {state: 0 sema: 0} writer Sem: 0 reader Sem: 0 reader Count: {: {} v: 0} reader Wait: {: {} v: 0} event Emitter: {eventsMutex: {state: 0 sema: 0} events: map [] hasInit: false} objectType: Request guide: request@82f9101b4ce55eb6e7fc73fcce599f14 Channel: 0xc000302cd0 objects: map[ response@2202f08970ce71dcc1d71734c6e5ac50 : 0xc0003e13f0 route@eecedbb07715dfa4b8e6df74b0dfa309 : 0xc0004043c0] eventToSubscriptionMapping: map [] connection: 0xc00011c2c0 initializer: map [frame: 0xc000302aa0 headers: [map [name: Accept value: text/HTML, application/xHTML+XML, application/XML; q=0.9, image/avif, image/webp, image/png, /; q=0.8, application/signed exchange; v=b3; q=0.7] map [name: Upgrade Ensure Request s value: 1] map [name: User Agent value: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/123.0.6312.4 Safari/537.36] isNavigationRequest: true method: GET resourceType: document URL: http://192.168.3.170/ ]Parent: 0xc000314180 wasCollected: false} timing: 0xc000388230 provisionalHeaders: 0xc00034c400 allHeaders:redirectedFrom:redirectedTo:FailureText: fallbackOverrides: 0xc0003f9c50}
Panel: interface conversion: interface {} is [] map [string] string, not [] interface {}
Goroutine 48 [running]:
Github. com/playwright community/playwright go. newRawHeaders ({0x914140?, 0xc000062db0})
/Home/u/goprojects/pkg/mod/github. com/playwright community/ [email protected] /Network. go: 48+0x4b1
Github. com/playwright community/playwright go (* requestImpl) Headers (0xc00041e030?)
/Home/u/goprojects/pkg/mod/github. com/playwright community/ [email protected] /Request. go: 73+0x35c
Test/crawleModule (* BrowserStruct). responseListener. func1()
/Mnt/d/5. project/1. go/testV4.0/crowlModule/browser. go: 371+0x7d
Created by test/crawleModule (* BrowserStruct). responseListener in goroutine 8
/Mnt/d/5. project/1. go/testV4.0/crowlModule/browser. go: 352+0xe5
Exit status 2
“
Headers, allHeaders, and headerArrays all have this issue
The text was updated successfully, but these errors were encountered: