Skip to content

HttpClient5 5.4.3 breaks local Docker transport #45028

Closed
@waileong

Description

@waileong

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions