Skip to content

Commit

Permalink
Add brackets in Host header of http request when relevant.
Browse files Browse the repository at this point in the history
See: mirage/ocaml-cohttp#997

Signed-off-by: Benjamin Reis <[email protected]>
  • Loading branch information
benjamreis committed Feb 8, 2024
1 parent 950ff05 commit 42ba1f8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
26 changes: 26 additions & 0 deletions SOURCES/xapi-23.31.0-fix-ipv6-import.XCP-ng.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Add brackets in `Host` header of http request when relevant.
See: https://github.com/mirage/ocaml-cohttp/issues/997

diff --git i/ocaml/xapi/xapi_vm.ml w/ocaml/xapi/xapi_vm.ml
index 4db86acbd..e310f5549 100644
--- i/ocaml/xapi/xapi_vm.ml
+++ w/ocaml/xapi/xapi_vm.ml
@@ -1518,7 +1518,17 @@ let rec import_inner n ~__context ~url ~sr ~full_restore ~force =
Cohttp.Request.Make (Cohttp_posix_io.Unbuffered_IO) in
let module Response =
Cohttp.Response.Make (Cohttp_posix_io.Unbuffered_IO) in
- let request = Cohttp.Request.make ~meth:`GET uri in
+ let headers = Cohttp.Header.init () in
+ let headers =
+ Cohttp.Header.add_unless_exists headers "host"
+ (match Uri.scheme uri with
+ | Some "httpunix" -> ""
+ | _ -> (
+ (Http.Url.maybe_wrap_IPv6_literal (Uri.host_with_default ~default:"localhost" uri))
+ ^
+ match Uri.port uri with Some p -> ":" ^ string_of_int p | None -> ""))
+ in
+ let request = Cohttp.Request.make ~meth:`GET ?headers:(Some headers) uri in
let ic =
{
Cohttp_posix_io.Unbuffered_IO.header_buffer= None
6 changes: 5 additions & 1 deletion SPECS/xapi.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Summary: xapi - xen toolstack for XCP
Name: xapi
Version: 23.31.0
Release: 1.1%{?xsrel}%{?dist}
Release: 1.2%{?xsrel}%{?dist}
Group: System/Hypervisor
License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
URL: http://www.xen.org
Expand Down Expand Up @@ -61,6 +61,7 @@ Patch1003: xapi-23.24.0-update-db-tunnel-protocol-from-other_config.XCP-ng.patch
# Needed for IPv6 support. Upstream wants a better fix. Drop when upstream fixed it.
Patch1004: xapi-23.3.0-filter-link-local-address-ipv6.XCP-ng.patch
Patch1005: xapi-23.31.0-extend-uefi-cert-api.patch
Patch1006: xapi-23.31.0-fix-ipv6-import.XCP-ng.patch

%{?_cov_buildrequires}
BuildRequires: ocaml-ocamldoc
Expand Down Expand Up @@ -1340,6 +1341,9 @@ Coverage files from unit tests
%{?_cov_results_package}

%changelog
* Thu Feb 08 2024 Benjamin Reis <[email protected]> - 23.31.0-1.2
- Add xapi-23.31.0-fix-ipv6-import.XCP-ng.patch

* Mon Jan 22 2024 Samuel Verschelde <[email protected]> - 23.31.0-1.1
- Rebase on 23.31.0-1
- Rediff patches (Benjamin Reis)
Expand Down

0 comments on commit 42ba1f8

Please sign in to comment.