Skip to contentSkip to conversation

Send non-standard port in host header of git://

PATCH New Shawn O. Pearce 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Send non-standard port in host header of git://

On a git://host:port/path style URL, if port is not the IANA registered port 9418 for git, the remote git daemon expects us to send "\0host=host:port\0" in the virtual host slot.

---
 .../spearce/jgit/transport/TransportGitAnon.java   |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitAnon.java +4 -0
index add7e2a..9edd93e 100644
@@ -103,6 +103,10 @@ void service(final String name, final PacketLineOut pckOut)
 		cmd.append('\0');
 		cmd.append("host=");
 		cmd.append(uri.getHost());
+		if (uri.getPort() != GIT_PORT) {
+			cmd.append(":");
+			cmd.append(uri.getPort());
+		}
 		cmd.append('\0');
 		pckOut.writeString(cmd.toString());
 		pckOut.flush();
Signature · 1 line
1.6.3.1.333.g3ebba7
#1 lore raw

PATCH v2 1/1 Send non-standard port in host header of git://

On a git://host:port/path style URL, if port is not the IANA registered port 9418 for git, the remote git daemon expects us to send "\0host=host:port\0" in the virtual host slot.

---
Arrrgh. v2 deals with the case when the port isn't in the URL at all, its <= 0, in which case its the default port, so we shouldn't send it to the server.

Sorry. :-)

 .../spearce/jgit/transport/TransportGitAnon.java   |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitAnon.java +4 -0
index add7e2a..0c80b9d 100644
@@ -103,6 +103,10 @@ void service(final String name, final PacketLineOut pckOut)
 		cmd.append('\0');
 		cmd.append("host=");
 		cmd.append(uri.getHost());
+		if (uri.getPort() > 0 && uri.getPort() != GIT_PORT) {
+			cmd.append(":");
+			cmd.append(uri.getPort());
+		}
 		cmd.append('\0');
 		pckOut.writeString(cmd.toString());
 		pckOut.flush();
Signature · 1 line
1.6.3.1.333.g3ebba7