Skip to content

Commit

Permalink
HTTP-redirects are obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
jfd committed Oct 8, 2013
1 parent e807ae4 commit 1c2fe85
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 57 deletions.
19 changes: 0 additions & 19 deletions src/hydna/net/Channel.as
Expand Up @@ -54,25 +54,6 @@ package hydna.net {

public static var PAYLOAD_MAX_SIZE:Number = Frame.PAYLOAD_MAX_SIZE;

/**
* Indicates if HTTP-redirects should be
* followed or not.
*
*/
public function get followRedirects() : Boolean {
return Connection.followRedirects;
}


/**
* @Returns {Boolean} true if HTTP-redirects should be
* followed, else false.
*/
public function set followRedirects(value:Boolean) : void {
Connection.followRedirects = value;
}


private var _id:uint = 0;
private var _url:String = null;
private var _token:String = null;
Expand Down
39 changes: 1 addition & 38 deletions src/hydna/net/Connection.as
Expand Up @@ -56,7 +56,6 @@ package hydna.net {
// Internal wrapper around flash.net.Socket
internal class Connection extends Socket {

private static const MAX_REDIRECT_ATTEMPTS:Number = 5;
private static const DEFAULT_PORT:Number = 80;

private static const BROADCAST_ALL:Number = 0;
Expand All @@ -69,8 +68,6 @@ package hydna.net {

private static var availableSockets:Dictionary;

public static var followRedirects:Boolean = true;

private var _attempt:Number;
private var _handshakeBuffer:String;

Expand Down Expand Up @@ -182,8 +179,7 @@ package hydna.net {
packet[1] = "Connection: Upgrade";
packet[2] = "Upgrade: winksock/1";
packet[3] = "Host: " + _urlobj.host;
packet[4] = "X-Accept-Redirects: " + (followRedirects ? "yes" : "no");
packet[5] = "\r\n";
packet[4] = "\r\n";

this.writeMultiByte(packet.join("\r\n"), "us-ascii");

Expand Down Expand Up @@ -267,39 +263,6 @@ package hydna.net {

return;

case 300:
case 301:
case 302:
case 303:
case 304:

if (followRedirects == false) {
destroy(new ChannelErrorEvent("Bad handshake (" +
"HTTP-redirection is disabled" +
")"));
return;
}

if (_attempt > MAX_REDIRECT_ATTEMPTS) {
destroy(new ChannelErrorEvent("Bad handshake (" +
"Too many redirect attempts" +
")"));
return;
}

for (var i:Number = 1; i < head.length; i++) {
m = /(\.):\s+(|.)/.exec(head[i]);
if (m && m[1].toLowerCase() == "host") {
handshake(URLParser.parse(m[2]));
return;
}
}

destroy(new ChannelErrorEvent("Bad handshake (" +
"Expected 'host' in redirect" +
")"));
return;

default:
destroy(new ChannelErrorEvent("Bad handshake (" +
status + " " + body +
Expand Down

0 comments on commit 1c2fe85

Please sign in to comment.