Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpClient5 5.4.3 breaks local Docker transport #45028

Closed
waileong opened this issue Apr 8, 2025 · 4 comments
Closed

HttpClient5 5.4.3 breaks local Docker transport #45028

waileong opened this issue Apr 8, 2025 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@waileong
Copy link

waileong commented Apr 8, 2025

HttpClient5 v5.4.3 breaks Spring Boot bootBuildImage with "malformed Host header"

Description

Spring Boot's bootBuildImage task fails with HTTP 400 when using HttpComponents Client 5.4.3 due to malformed Host headers being sent to Docker.

Reproduction

You can reproduce this issue with this sample project: https://github.com/waileong/springboot-bootbuildimage-hc5

Or manually:

  1. Create a Spring Boot project with this build.gradle:
    buildscript {
        configurations.configureEach {
            resolutionStrategy {
                force 'org.apache.httpcomponents.client5:httpclient5:5.4.3'
            }
        }
    }
    plugins {
        id 'java'
        id 'org.springframework.boot' version '3.4.4'
        id 'io.spring.dependency-management' version '1.1.7'
    }
    // rest of standard Spring Boot config
  2. Run ./gradlew bootBuildImage

Error

Docker API call failed with status code 400 "Bad Request: malformed Host header"

Debug logs show:

>> "Host: npipe:////./pipe/dockerDesktopLinuxEngine[\r][\n]"
<< "HTTP/1.1 400 Bad Request: malformed Host header"

Cause

Commit 57d5a1376 - "DefaultHost: derive default host name from target address" - changed how Host headers are derived.

The Host header now includes the full URI scheme for named pipes:

Host: npipe:////./pipe/dockerDesktopLinuxEngine

This violates HTTP/1.1 spec and breaks Docker API communication.

Workaround

Pin to HttpClient 5.4.2:

force 'org.apache.httpcomponents.client5:httpclient5:5.4.2'

Environment

  • Spring Boot 3.4.4
  • Java 17
  • Docker Desktop with named pipes

Request

Please fix Host header generation for non-HTTP URI schemes (named pipes/unix sockets). Consider using "localhost" or allowing custom Host values for these cases.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 8, 2025
@mhalbritter mhalbritter self-assigned this Apr 8, 2025
@mhalbritter mhalbritter changed the title HttpClient5 v5.4.3 breaks Spring Boot BootBuildImage with "malformed Host header" Explicitly set Host header for local Docker transport Apr 8, 2025
@mhalbritter mhalbritter added type: enhancement A general enhancement type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Apr 8, 2025
@mhalbritter mhalbritter changed the title Explicitly set Host header for local Docker transport HttpClient5 v5.4.3 breaks local Docker transport Apr 8, 2025
@mhalbritter mhalbritter changed the title HttpClient5 v5.4.3 breaks local Docker transport HttpClient5 5.4.3 breaks local Docker transport Apr 8, 2025
@mhalbritter
Copy link
Contributor

The change, https://issues.apache.org/jira/browse/HTTPCLIENT-2363, is applied to 5.4.3 onwards, which means Boot 3.4 and 3.5 is affected.

@mhalbritter
Copy link
Contributor

It's now working when we do the httpclient 5.4.3 update.

@mhalbritter
Copy link
Contributor

Thanks @waileong for letting us know and for the detailed analysis!

@waileong
Copy link
Author

waileong commented Apr 9, 2025

You're welcome! Glad it helped. Let me know if you need anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants