Code Monkey home page Code Monkey logo

http1.1's Introduction

HTTP1.1

A C++ implementation of HTTP/1.1 that support TLS

Requirements

  • Version of g++ new enough to support C++11
  • OpenSSL >= 1.0.2 Note: I have only tested this on Linux

#Usage example:

#include <iostream>
#include <fstream>
#include <string>
#include "HTTP.hpp"

using namespace std;

int main(const int argc, const char **argv) {
	if(argc != 4) {
		cout << "Usage: " << argv[0] << " host target output" << endl;
		cout << "\tExample: ./get https://www.google.com / index.html" << endl;
		return 0;
	}
	cout << "Connection to host " << argv[1] << "..." << endl;
	Client c(argv[1]);
	c.headers.insert("User-Agent", "Adrian's HTTP client");
	c.headers.insert("Connection", "close");

	cout << "Fetching page " << argv[2] << "..." << endl;
	Reply r = c.get(argv[2]);

	cout << "Status: " << r.status << endl;
	cout << "Responce Headers: " << endl;
	for(auto &h : r.headers) {
		cout << h.first << ": " << h.second << endl;
	}

	cout << "Saving to file " << argv[3] << "..." << endl;
	ofstream output(argv[3], ios::out | ios::binary);
	output.write(r.body.get(), r.length);

	cout << "Done!!!" << endl;
	return 0;
}

http1.1's People

Contributors

adrs avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.