Merge pull request #77 from Spmoolman/master
Added check to see if the request is empty
This commit is contained in:
commit
714482d903
|
@ -61,28 +61,41 @@ namespace AsterNET.FastAGI
|
|||
var reader = new AGIReader(socket);
|
||||
var writer = new AGIWriter(socket);
|
||||
AGIRequest request = reader.ReadRequest();
|
||||
|
||||
//Added check for when the request is empty
|
||||
//eg. telnet to the service
|
||||
if (request.Request.Count > 0)
|
||||
{
|
||||
var channel = new AGIChannel(writer, reader, _SC511_CAUSES_EXCEPTION, _SCHANGUP_CAUSES_EXCEPTION);
|
||||
AGIScript script = mappingStrategy.DetermineScript(request);
|
||||
Thread.SetData(_channel, channel);
|
||||
|
||||
if (script != null)
|
||||
{
|
||||
#if LOGGER
|
||||
#if LOGGER
|
||||
logger.Info("Begin AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
|
||||
#endif
|
||||
#endif
|
||||
script.Service(request, channel);
|
||||
#if LOGGER
|
||||
#if LOGGER
|
||||
logger.Info("End AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = "No script configured for URL '" + request.RequestURL + "' (script '" + request.Script +
|
||||
"')";
|
||||
channel.SendCommand(new VerboseCommand(error, 1));
|
||||
#if LOGGER
|
||||
#if LOGGER
|
||||
logger.Error(error);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = "A connection was made with no requests";
|
||||
#if LOGGER
|
||||
logger.Error(error);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (AGIHangupException)
|
||||
|
@ -93,19 +106,19 @@ namespace AsterNET.FastAGI
|
|||
}
|
||||
catch (AGIException ex)
|
||||
{
|
||||
#if LOGGER
|
||||
#if LOGGER
|
||||
logger.Error("AGIException while handling request", ex);
|
||||
#else
|
||||
#else
|
||||
throw ex;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if LOGGER
|
||||
#if LOGGER
|
||||
logger.Error("Unexpected Exception while handling request", ex);
|
||||
#else
|
||||
#else
|
||||
throw ex;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
Thread.SetData(_channel, null);
|
||||
|
@ -113,14 +126,14 @@ namespace AsterNET.FastAGI
|
|||
{
|
||||
socket.Close();
|
||||
}
|
||||
#if LOGGER
|
||||
#if LOGGER
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.Error("Error on close socket", ex);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
catch { }
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue