antes de a?adir la clase Comic de YACReader a YACReaderLibrary

navegaci?n web con paginaci?n rudimentaria implementada
This commit is contained in:
Luis Ángel San Martín
2012-09-05 19:41:52 +02:00
parent 2afe3101b1
commit cbee662df4
33 changed files with 515 additions and 30 deletions

View File

@ -26,7 +26,8 @@ HttpConnectionHandler* HttpConnectionHandlerPool::getConnectionHandler() {
}
}
if (!freeHandler) {
int maxConnectionHandlers=settings->value("maxThreads",10).toInt();
//CAMBIADO
int maxConnectionHandlers= 100;//settings->value("maxThreads",10).toInt();
if (pool.count()<maxConnectionHandlers) {
freeHandler=new HttpConnectionHandler(settings,requestHandler);
pool.append(freeHandler);

View File

@ -50,6 +50,7 @@ void HttpListener::incomingConnection(int socketDescriptor) {
QTcpSocket* socket=new QTcpSocket(this);
socket->setSocketDescriptor(socketDescriptor);
connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
//CAMBIADO 503 por 429
socket->write("HTTP/1.1 503 too many connections\r\nConnection: close\r\n\r\nToo many connections\r\n");
socket->disconnectFromHost();
}

View File

@ -104,6 +104,11 @@ void HttpResponse::write(QByteArray data, bool lastPart) {
}
}
void HttpResponse::writeText(QString text, bool lastPart)
{
write(text.toAscii(),lastPart);
}
bool HttpResponse::hasSentLastPart() const {
return sentLastPart;

View File

@ -83,6 +83,7 @@ public:
@param lastPart Indicator, if this is the last part of the response.
*/
void write(QByteArray data, bool lastPart=false);
void writeText(QString text, bool lastPart=false);
/**
Indicates wheter the body has been sent completely. Used by the connection

View File

@ -119,6 +119,8 @@ void StaticFileController::setContentType(QString fileName, HttpResponse& respon
else if (fileName.endsWith(".html") || fileName.endsWith(".htm")) {
response.setHeader("Content-Type", qPrintable("text/html; charset=charset="+encoding));
}
else if (fileName.endsWith(".js"))
response.setHeader("Content-Type", qPrintable("text/javascript; charset=charset="+encoding));
// Todo: add all of your content types
}