Skip to content

maukkis/meowHttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meowHttp

a simple C++ library to send https and wss requests

Dependencies

  • openssl

Usage

https get request

#include "includes/https.h"

int main(){
  auto meow = meowHttp::Https()
    .setUrl("https://example.tld");
  meow.perform();
  return 0;
}

https post request

#include "includes/https.h"

int main(){
  auto meow = meowHttp::Https()
    .setUrl("https://url.here")
    .setPostfields("post here");
  meow.perform();
  return 0;
}

websockets

#include "includes/websocket.h"
#include <iostream>

int main(){
  auto websocket = meowWs::Websocket()
    .setUrl("https://url here nya");
  if(websocket.perform() != OK){
    return 1;
  }
  std::string buf;
  struct meowWs::meowWsFrame frame;
  while(true){
    if(websocket.wsRecv(buf, &frame) >= 1){
      std::cout << "received data breaking\n";
      break;
    } 
  }
  std::cout << buf << '\n';
  buf.resize(0);
  websocket.wsSend("ping!", meowWs::meowWS_PING);
  while(true){
    if(websocket.wsRecv(buf, &frame) >= 1){
      std::cout << "received data breaking\n";
      break;
    } 
  }
  std::cout << buf << '\n'; 
  return 0;
}

About

Mirror of meowHttp. Main repo located at https://git.girlsmell.xyz/luna/http-client

Resources

License

Stars

Watchers

Forks

Packages

No packages published