Skip to content

[BUG] Align OkHttp and Netty handling of HTTP 407 responses after HTTPS tunnel establishment #50799

Closed

Description

@g2vinay

Describe the bug
The OkHttp and Netty HTTP transports handle an HTTP 407 response differently when it is returned by an HTTPS endpoint after an HTTP proxy CONNECT tunnel has already been established.

The response is an endpoint response received over the established TLS connection, not a response to the proxy CONNECT request. However, the OkHttp path can invoke proxy-specific handling and issue a follow-up request, while the Netty path treats it as an endpoint response without restarting proxy negotiation.

This issue tracks consistent HTTP response handling when applications switch between transports.

Exception or Stack Trace
Not applicable. This is a response-handling and retry-behavior difference rather than an exception report.

To Reproduce
Use a controlled local test environment:

  1. Configure an HTTP proxy and an HTTPS test endpoint.
  2. Allow proxy CONNECT negotiation and TLS establishment to complete normally.
  3. Have the HTTPS test endpoint return HTTP 407 (Proxy Authentication Required) over the established TLS connection.
  4. Send the same request using azure-core-http-okhttp and azure-core-http-netty with equivalent proxy settings.
  5. Compare the transport-level response handling and whether a proxy-related follow-up is attempted.

The behavior below is based on implementation review; these steps have not been run locally for this tracking issue.

Transport Behavior for the endpoint-generated 407 after tunnel establishment
OkHttp OkHttp can invoke the configured proxy authenticator for this response. The SDK authenticator does not distinguish it from a CONNECT-phase response and can produce a proxy-related follow-up request.
Netty Proxy negotiation is handled during CONNECT. Once the tunnel is established, an endpoint-generated 407 does not re-enter the proxy authentication path; it remains an endpoint response for the SDK pipeline/caller to handle.

Code Snippet
No application snippet is included. The HTTPS test fixture should return status 407 after successful CONNECT and TLS establishment. Use existing proxy test fixtures and compare transport-level behavior independently of service-specific retry policies.

Expected behavior
An endpoint-generated HTTP 407 received inside an established HTTPS tunnel should not restart proxy negotiation. OkHttp and Netty should behave consistently for this scenario.

Acceptance criteria:

  • Align OkHttp post-tunnel 407 handling with Netty's connection-phase behavior.
  • Preserve normal handling of genuine proxy 407 responses during CONNECT.
  • Preserve supported cleartext HTTP proxy behavior.
  • Add regression tests for post-tunnel 407 responses, including reuse of an established connection.
  • Cover HTTP/1.1 and HTTP/2 endpoint connections where supported.

Screenshots
Not applicable.

Setup (please complete the following information):

  • OS: Not OS-specific; implementation review.
  • IDE: Not applicable.
  • Library/Libraries: com.azure:azure-core-http-okhttp (reviewed at 1.14.0-beta.1, with OkHttp 4.12.0) and com.azure:azure-core-http-netty for behavior comparison.
  • Java version: No local runtime reproduction performed for this tracking issue.
  • App Server/Environment: Java application using an Azure SDK HTTP transport through an HTTP proxy to a controlled HTTPS endpoint.
  • Frameworks: None required.

A dependency version mismatch is not suspected. Dependency-tree output and exception logs are not applicable to this tracking issue.

Additional context
Review the OkHttp ProxyAuthenticator and its builder integration against the Netty proxy handling lifecycle. The goal is transport parity and predictable response handling, not a public API change. Keep the change focused on distinguishing CONNECT-phase responses from endpoint responses and adding related regression coverage.

Information Checklist

  • Bug Description Added
  • Repro Steps Added (controlled test scenario provided; not executed locally)
  • Setup information Added

Activity

  1. added
    ClientThis issue points to a problem in the data-plane of the library.
    on Oct 14, 2026
  2. github-actions commented on Oct 14, 2026

    @github-actions
    Contributor

    Thank you for your feedback. Tagging and routing to the team member(s) best able to assist.

    Generated by Agentic Triage for #50799 · auto · 38.6 AIC · ⌖ 4 AIC · ⊞ 16.2K · ◷

  3. github-actions commented on Oct 14, 2026

    @github-actions
    Contributor

    🎯 Agentic Issue Triage

    Summary: The OkHttp and Netty HTTP transports in azure-core handle an endpoint-generated HTTP 407 (returned after an HTTPS CONNECT tunnel is already established) inconsistently — OkHttp can re-invoke proxy authentication handling for it, while Netty treats it purely as an endpoint response.

    📋 Issue Details

    Package: com.azure:azure-core-http-okhttp (reviewed at 1.14.0-beta.1, OkHttp 4.12.0), compared against com.azure:azure-core-http-netty
    Affected API: OkHttp ProxyAuthenticator and its builder integration vs. Netty's proxy/CONNECT handling lifecycle
    Scenarios:

    • An HTTP proxy CONNECT tunnel to an HTTPS endpoint is established successfully.
    • The endpoint itself (not the proxy) returns HTTP 407 over the already-established TLS connection.
    • OkHttp's authenticator can misinterpret this as a proxy auth challenge and issue a follow-up request; Netty does not re-enter proxy negotiation for it.

    Root ask: Align OkHttp's post-tunnel 407 handling with Netty's, so an endpoint-generated 407 inside an established tunnel does not restart proxy negotiation, while preserving correct behavior for genuine CONNECT-phase 407s and cleartext HTTP proxy scenarios. Regression tests covering HTTP/1.1 and HTTP/2 are requested.

    🔎 Debugging / Reproduction Notes

    This is a tracking/design issue based on implementation review rather than an executed repro; no stack trace or exception is involved — it's a behavioral-parity concern between two azure-core HTTP transport implementations.

    Suggested investigation steps:

    1. Review ProxyAuthenticator in azure-core-http-okhttp to determine how it distinguishes CONNECT-phase 407 responses from endpoint-returned 407 responses over an already-tunneled connection.
    2. Compare against Netty's proxy handler lifecycle in azure-core-http-netty to confirm it never re-enters proxy auth once the tunnel is established.
    3. Add regression tests simulating: (a) genuine CONNECT 407, (b) endpoint 407 post-tunnel, and (c) cleartext HTTP proxy 407, across HTTP/1.1 and HTTP/2 where supported.

    Note: Automated reference-issue search via gh search was unavailable in this environment (tool returned an error), so no duplicate/similar-issue check could be performed.

    🏷️ Label Confidence
    • Category: Client — The issue is about SDK transport implementation behavior (azure-core-http-okhttp/azure-core-http-netty), not REST API/service behavior or engineering systems.
    • Service: Azure.Core — Both affected packages live under sdk/core/, which maps to the Azure.Core service label per CODEOWNERS.
    • Confidence: High — The issue explicitly names both packages, clearly scopes the problem to SDK-internal transport behavior, and aligns with standard sdk/core/ package routing.
    👥 Owner Routing
    • Matched CODEOWNERS entry: # ServiceLabel: %Azure.Core (sdk/core/ section) — matched because the predicted service label is Azure.Core and this entry lists an AzureSdkOwner.
    • AzureSdkOwners: @alzimmermsft
    • ServiceOwners: none listed
    • Routing action: Assigned @alzimmermsft as the sole AzureSdkOwner for this entry.
    • Scan notes: Scanned bottom-to-top; entries like %ARM - Core, %clientcore, %Azure.Core.V2, and %Azure.Core.AMQP were checked but required different/additional labels not present on this issue (e.g., Mgmt, AMQP-specific), so the general %Azure.Core entry under /sdk/core/ was the correct match.

    Generated by Agentic Triage for #50799 · auto · 38.6 AIC · ⌖ 4 AIC · ⊞ 16.2K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Azure.Coreazure-coreClientThis issue points to a problem in the data-plane of the library.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions