Commit 8c8347a2 authored by jan.koester's avatar jan.koester
Browse files

it works

parent 582b7b54
Loading
Loading
Loading
Loading
+8 −8
Changes for examples/httpauth.cpp: 8 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -39,14 +39,14 @@

class Controller : public libhttppp::HttpEvent {
public:
    Controller(std::shared_ptr<netplus::socket> serversocket) : HttpEvent(serversocket){
    Controller(netplus::socket &serversocket) : HttpEvent(serversocket){
        
    };
    
    void RequestEvent(std::shared_ptr<libhttppp::HttpRequest> &curreq, const int tid,ULONG_PTR args){
    void RequestEvent(libhttppp::HttpRequest &curreq, const int tid,ULONG_PTR args){
        try{
            std::cout << "Parse Request\n" << std::endl;
            if(curreq->getRequestURL()=="/"){
            if(curreq.getRequestURL()=="/"){
                libhttppp::HttpResponse curres;
                curres.setState(HTTP200);
                curres.setVersion(HTTPVERSION(1.1));
@@ -67,8 +67,8 @@ public:
                libhtmlpp::HtmlString html;
                libhtmlpp::print(condat.parse(),html);
                curres.send(curreq,html.data(),html.size());
            }else if(curreq->getRequestURL()=="/httpbasicauth" ||
                curreq->getRequestURL()== "/httpdigestauth"){
            }else if(curreq.getRequestURL()=="/httpbasicauth" ||
                curreq.getRequestURL()== "/httpdigestauth"){
                libhttppp::HttpAuth httpauth;
            httpauth.parse(curreq);
            const char *username=httpauth.getUsername();
@@ -100,13 +100,13 @@ public:
                    curres.setState(HTTP401);
                    curres.setVersion(HTTPVERSION(1.1));
                    curres.setContentType(nullptr);
                    if(curreq->getRequestURL()=="/httpbasicauth"){
                    if(curreq.getRequestURL()=="/httpbasicauth"){
                        httpauth.setAuthType(BASICAUTH);
                    }else if(curreq->getRequestURL()=="/httpdigestauth"){
                    }else if(curreq.getRequestURL()=="/httpdigestauth"){
                        httpauth.setAuthType(DIGESTAUTH);
                    }
                    httpauth.setRealm("httpauthtest");
                    httpauth.setAuth(std::make_shared<libhttppp::HttpResponse>(curres));
                    httpauth.setAuth(curres);
                    curres.send(curreq,std::vector<char>(),0);
                    return;
                }
+5 −5
Changes for examples/httpcon.cpp: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "http.h"
#include "httpd.h"

void sendResponse(std::shared_ptr<libhttppp::HttpRequest> &curreq) {
void sendResponse(libhttppp::HttpRequest &curreq) {
     libhttppp::HttpResponse curres;
     curres.setState(HTTP200);
     curres.setVersion(HTTPVERSION(1.1));
@@ -50,9 +50,9 @@ void sendResponse(std::shared_ptr<libhttppp::HttpRequest> &curreq) {
             << "    <style> </style>"
             << "  </head>"
             << "<body>";
     if(curreq->isMobile())
     if(curreq.isMobile())
         condat << "<span>You are using a mobile Browser!</span><br>";
     for(libhttppp::HttpHeader::HeaderData *preq = curreq->getfirstHeaderData(); preq; preq=preq->nextHeaderData()){
     for(libhttppp::HttpHeader::HeaderData *preq = curreq.getfirstHeaderData(); preq; preq=preq->nextHeaderData()){
       condat  << preq->getkey()
               << ": ";
       for(libhttppp::HttpHeader::HeaderData::Values *cval=preq->getfirstValue(); cval; cval=cval->nextvalue()){
@@ -69,10 +69,10 @@ void sendResponse(std::shared_ptr<libhttppp::HttpRequest> &curreq) {

class Controller : public libhttppp::HttpEvent {
public:
    Controller(std::shared_ptr<netplus::socket> serversocket) : HttpEvent(serversocket){
    Controller(netplus::socket &serversocket) : HttpEvent(serversocket){
        
    };
    void RequestEvent(std::shared_ptr<libhttppp::HttpRequest> curreq, const int tid,ULONG_PTR args){
    void RequestEvent(libhttppp::HttpRequest &curreq, const int tid,ULONG_PTR args){
        try{
            std::cout << "Send answer" << std::endl;
            sendResponse(curreq);
+5 −5
Changes for examples/httpcookie.cpp: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@

class CookieTest {
public:
    CookieTest(std::shared_ptr<libhttppp::HttpRequest> &curreq) : _Curreq(curreq) {
    CookieTest(libhttppp::HttpRequest &curreq) : _Curreq(curreq) {
        _Curres.setState(HTTP200);
        _Curres.setVersion(HTTPVERSION(1.1));
        _Curres.setContentType("text/html"); 
@@ -107,7 +107,7 @@ public:
        libhttppp::HttpForm curform;
        curform.parse(_Curreq);
        if(getData("key",curform)!=nullptr){
            _Cookie.setcookie(std::make_shared<libhttppp::HttpResponse>(_Curres),getData("key",curform),getData("value",curform),getData("comment",curform),getData("domain",curform),
            _Cookie.setcookie(_Curres,getData("key",curform),getData("value",curform),getData("comment",curform),getData("domain",curform),
                              getDataInt("max-age",curform),getData("path",curform),false,getData("version",curform));
        }
    };
@@ -127,15 +127,15 @@ private:
    libhtmlpp::HtmlString                   _HTMLDat;
    libhttppp::HttpCookie                   _Cookie;
    libhttppp::HttpResponse                 _Curres;
    std::shared_ptr<libhttppp::HttpRequest> &_Curreq;
    libhttppp::HttpRequest                 &_Curreq;
};

class Controller : public libhttppp::HttpEvent {
public:
    Controller(std::shared_ptr<netplus::socket> serversocket) : HttpEvent(serversocket){
    Controller(netplus::socket& serversocket) : HttpEvent(serversocket){
        
    };
    void RequestEvent(std::shared_ptr <libhttppp::HttpRequest> &curreq, const int tid,ULONG_PTR args){
    void RequestEvent(libhttppp::HttpRequest &curreq, const int tid,ULONG_PTR args){
        try{
            std::cout << "Send answer" << std::endl;
            CookieTest ctest(curreq);
+3 −3
Changes for examples/httphello.cpp: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -36,14 +36,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class Controller : public libhttppp::HttpEvent {
public:
    Controller(std::shared_ptr<netplus::socket> serversocket) : HttpEvent(serversocket){
    Controller(netplus::socket &serversocket) : HttpEvent(serversocket){
        
    };
    void RequestEvent(std::shared_ptr<libhttppp::HttpRequest> &curreq, const int tid,ULONG_PTR args){
    void RequestEvent(libhttppp::HttpRequest &curreq, const int tid,ULONG_PTR args){
        try{
            libhttppp::HttpResponse curres;
            std::vector<char> hello;
			std::copy(HTMLHELLO, HTMLHELLO + sizeof(HTMLHELLO) - 1, std::back_inserter(hello));
			std::copy(HTMLHELLO, HTMLHELLO + sizeof(HTMLHELLO), std::back_inserter(hello));
            curres.setContentType("text/html");
            curres.send(curreq,hello,hello.size());
        }catch(libhttppp::HTTPException &e){
+4 −4
Changes for examples/httpproxy.cpp: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "http.h"
#include "httpd.h"

void sendResponse(std::shared_ptr<libhttppp::HttpRequest> &curreq) {
void sendResponse(libhttppp::HttpRequest &curreq) {
     libhttppp::HttpResponse curres;
     curres.setState(HTTP200);
     curres.setVersion(HTTPVERSION(1.1));
@@ -51,7 +51,7 @@ void sendResponse(std::shared_ptr<libhttppp::HttpRequest> &curreq) {
             << "  </head>"
             << "<body>";

     for(libhttppp::HttpHeader::HeaderData *preq = curreq->getfirstHeaderData(); preq; preq=preq->nextHeaderData()){
     for(libhttppp::HttpHeader::HeaderData *preq = curreq.getfirstHeaderData(); preq; preq=preq->nextHeaderData()){
       condat  << preq->getkey()
               << ": ";
       for(libhttppp::HttpHeader::HeaderData::Values *cval=preq->getfirstValue(); cval; cval=cval->nextvalue()){
@@ -69,10 +69,10 @@ void sendResponse(std::shared_ptr<libhttppp::HttpRequest> &curreq) {

class Controller : public libhttppp::HttpEvent {
public:
    Controller(std::shared_ptr<netplus::socket> serversocket) : HttpEvent(serversocket){
    Controller(netplus::socket &serversocket) : HttpEvent(serversocket){
        
    };
    void RequestEvent(std::shared_ptr<libhttppp::HttpRequest> &curreq, const int tid,ULONG_PTR args){
    void RequestEvent(libhttppp::HttpRequest &curreq, const int tid,ULONG_PTR args){
        try{
            std::cout << "Send answer"  << std::endl;
            sendResponse(curreq);
Loading