Skip to content
Browse files

Fix for Bug http://code.google.com/p/red5/issues/detail?id=159 . Than…

…ks to Richard for reporting and sending patch.

git-svn-id: http://red5.googlecode.com/svn/java/server/trunk@4298 1b6495e4-3631-0410-8e05-8f51eee8b9cc
  • Loading branch information...
1 parent 5cbe659 commit f5e190320f56551ec62953ad5d543ecfd6c99701 tiago.jacobs committed
View
6 src/org/red5/server/net/mrtmp/EdgeRTMPHandler.java
@@ -140,12 +140,6 @@ protected void handleConnect(RTMPConnection conn, Channel channel, Header header
// Get hostname
String host = getHostname((String) params.get("tcUrl"));
- // Check up port
- if (host.endsWith(":1935")) {
- // Remove default port from connection string
- host = host.substring(0, host.length() - 5);
- }
-
// App name as path, but without query string if there is one
String path = (String) params.get("app");
if (path.indexOf("?") != -1) {
View
9 src/org/red5/server/net/rtmp/BaseRTMPHandler.java
@@ -228,7 +228,14 @@ protected String getHostname(String url) {
// TODO: is this a good default hostname?
return "";
} else {
- return parts[2];
+ String host = parts[2];
+ // Strip out default port in case the client
+ // added the port explicitly.
+ if (host.endsWith(":1935")) {
+ // Remove default port from connection string
+ return host.substring(0, host.length() - 5);
+ }
+ return host;
}
}
View
6 src/org/red5/server/net/rtmp/RTMPHandler.java
@@ -208,11 +208,7 @@ protected void onInvoke(RTMPConnection conn, Channel channel, Header source, Not
final Map<String, Object> params = invoke.getConnectionParams();
// Get hostname
String host = getHostname((String) params.get("tcUrl"));
- // Check up port
- if (host.endsWith(":1935")) {
- // Remove default port from connection string
- host = host.substring(0, host.length() - 5);
- }
+
// App name as path, but without query string if there is
// one
String path = (String) params.get("app");
View
6 src/org/red5/server/net/rtmpt/RTMPTConnection.java
@@ -108,6 +108,12 @@ protected void onInactive() {
*/
public void setServletRequest(HttpServletRequest request) {
host = request.getLocalName();
+ // Check if the request came in from the default port.
+ // We strip default ports so don't include it in the host.
+ if (request.getLocalPort() != 80) {
+ host += ":" + request.getLocalPort();
+ }
+
remoteAddress = request.getRemoteAddr();
remoteAddresses = ServletUtils.getRemoteAddresses(request);
remotePort = request.getRemotePort();
View
26 src/org/red5/server/net/rtmpt/RTMPTHandler.java
@@ -72,6 +72,32 @@ public void setCodecFactory(RTMPTCodecFactory factory) {
public RTMPTCodecFactory getCodecFactory() {
return this.codecFactory;
}
+
+ /**
+ * Return hostname for URL.
+ *
+ * @param url
+ * URL
+ * @return Hostname from that URL
+ */
+ @Override
+ protected String getHostname(String url) {
+ log.debug("url: {}", url);
+ String[] parts = url.split("/");
+ if (parts.length == 2) {
+ // TODO: is this a good default hostname?
+ return "";
+ } else {
+ String host = parts[2];
+ // Strip out default port in case the client
+ // added the port explicitly.
+ if (host.endsWith(":80")) {
+ // Remove default port from connection string
+ return host.substring(0, host.length() - 3);
+ }
+ return host;
+ }
+ }
/**
* Handle raw buffer received
View
7 src/org/red5/server/net/rtmpt/RTMPTServlet.java
@@ -319,6 +319,7 @@ protected void handleOpen(HttpServletRequest req, HttpServletResponse resp) thro
// TODO: should we evaluate the pathinfo?
RTMPTConnection connection = createConnection();
connection.setServlet(this);
+ connection.setServletRequest(req);
if (connection.getId() != 0) {
// Return connection id to client
returnMessage(connection.getId() + "\n", resp);
@@ -350,8 +351,9 @@ protected void handleClose(HttpServletRequest req, HttpServletResponse resp) thr
handleBadRequest(String.format("Close: unknown client with id: %s", getClientId(req)), resp);
return;
}
+
removeConnection(connection.getId());
- connection.setServletRequest(req);
+
handler.connectionClosed(connection, connection.getState());
returnMessage((byte) 0, resp);
connection.realClose();
@@ -381,8 +383,6 @@ protected void handleSend(HttpServletRequest req, HttpServletResponse resp) thro
return;
}
- connection.setServletRequest(req);
-
// Put the received data in a ByteBuffer
int length = req.getContentLength();
IoBuffer data = IoBuffer.allocate(length);
@@ -446,7 +446,6 @@ protected void handleIdle(HttpServletRequest req, HttpServletResponse resp) thro
return;
}
- connection.setServletRequest(req);
returnPendingMessages(connection, resp);
}

0 comments on commit f5e1903

Please sign in to comment.
Something went wrong with that request. Please try again.