Commit 6dd18561 authored by jan.koester's avatar jan.koester
Browse files

initial work client

parent a2c0fb6d
Loading
Loading
Loading
Loading
+1 −1
Changes for .kdev4/libhttppp.kdev4: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ CMake Binary=/usr/bin/cmake
CMake Executable=/usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=
Install Directory=/usr/local
Runtime=Host System

[Project]
+3 −0
Changes for examples/CMakeLists.txt: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -23,3 +23,6 @@ if(BUILD_EXAMPLES AND ${htmlpp_FOUND})
    add_executable (httphello httphello.cpp)
    target_link_libraries(httphello httppp-static htmlpp-static)
endif()

add_executable (httpclient httpclient.cpp)
target_link_libraries(httpclient httppp-static)
+31 −0
Changes for examples/httpclient.cpp: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*******************************************************************************
Copyright (c) 2014, Jan Koester jan.koester@gmx.net
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include "http.h"

int main(int argc, char** argv){
}
+29 −0
Changes for src/http.cpp: 29 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -283,6 +283,11 @@ void libhttppp::HttpResponse::send(netplus::con* curconnection,const char* data,
  curconnection->sending(true);
}

void libhttppp::HttpResponse::parse(netplus::con* curconnection){

}


libhttppp::HttpResponse::~HttpResponse(){
}

@@ -454,6 +459,30 @@ size_t libhttppp::HttpRequest::getRequestLength() {
    return _Request.length();
}

void libhttppp::HttpRequest::setRequestData(const char* data, size_t len){
  _Request.clear();
  _Request.resize(len);
  _Request.insert(0,data);
}

void libhttppp::HttpRequest::setRequestType(int req){
  if(req == POSTREQUEST || req == GETREQUEST){
    _RequestType=req;
    return;
  }
   HTTPException excep;
   excep[HTTPException::Error] << "setRequestType: " << "Unknown Request will not set !";
   throw excep;
}

void libhttppp::HttpRequest::setRequestURL(const char* url){
  if(url)
    _RequestURL=url;
  else
    _RequestURL.clear();
}


libhttppp::HttpRequest::~HttpRequest(){
}

+15 −1
Changes for src/http.h: 15 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -84,14 +84,21 @@ namespace libhttppp {
  public:
    HttpResponse();
    ~HttpResponse();

    void   setState(const char *httpstate);
    void   setContentType(const char *type);
    void   setContentLength(size_t len);
    void   setConnection(const char *type);
    void   setVersion(const char* version);

    size_t printHeader(std::string &buffer);

    /*server methods*/
    void   send(netplus::con *curconnection,const char* data);
    void   send(netplus::con *curconnection,const char* data, unsigned long datalen); //only use as server
    size_t printHeader(std::string &buffer);

    /*client method*/
    void   parse(netplus::con *curconnection);
  private:
    std::string      _State;
    std::string      _Version;
@@ -105,12 +112,19 @@ namespace libhttppp {
  public:
    HttpRequest();
    ~HttpRequest();
    /*server methods*/
    void           parse(netplus::con *curconnection); //only use as server
    size_t         printHeader(char **buffer);
    int            getRequestType();
    const char    *getRequestURL();
    const char    *getRequest();
    size_t         getRequestLength();
    /*Client methods*/
    void           setRequestType(int req);
    void           setRequestURL(const char *url);
    /*only for post Reuquesttype*/
    void           setRequestData(const char *data,size_t len);

  private:
    std::string    _Request;
    int            _RequestType;