Noooste / azuretls-client

An easy-to-use HTTP client 100% in Go to spoof TLS/JA3 and HTTP2 fingerprint
MIT License
172 stars 25 forks source link

[BUG] invalid context is returned #72

Closed VegieIsCute closed 7 months ago

VegieIsCute commented 7 months ago

Describe the bug When context is retrieved from a callback, the provided context is invalid.

To Reproduce

exampleContext, _ := context.WithCancel(context.Background())
    session := azuretls.NewSessionWithContext(exampleContext)

    session.CallbackWithContext = func(ctx *azuretls.Context) {
        exampleContextFromCtx := ctx.Context()
        if exampleContextFromCtx == exampleContext {
            fmt.Println("match")
        } else {
            fmt.Println("no match")
            session1 := azuretls.NewSessionWithContext(exampleContextFromCtx)
            _, err := session1.Get("https://httpbin.org/headers")

            if err != nil {
                log.Fatal(err)
            }
        }
    }

    _, _ = session.Get("https://httpbin.org/headers")

Expected behavior The request inside the callback should work, but errors with a "canceled" message, even though context wasn't canceled. This is because an invalid context is being returned.

Screenshots image

Desktop (please complete the following information):

Noooste commented 7 months ago

It's patched v1.4.8