Giter Club home page Giter Club logo

my_curl's Introduction

my_curl

A recreation of the curl command.

Task

Create a my_curl command (very similar to the UNIX command curl). my_curl is a tool to get data from a server, using HTTP. The command is designed to work without user interaction.

How does it work? You send a url as parameter and it will print the html content of a web page.

my_curl only supports HTTP.

Description

To make an http request for the raw html data of any given website requires the url address to be correctly formatted. Next, a socket must be created and a connection initiated with the host server. An http request is then sent via write() and the response is received via read().

Complexity: To correctly format the url address, one must remove prefixes if any were present in the argument ("http://" etc.), and tokenize the rest of address into the hostname and path.

Before creating a socket one must retreive the IP address and related network info via getaddrinfo(). getaddrinfo() requires 4 parameters, the hostname, the port (in this case "80" as we are requesting data from a standard website), and 2 struct addrinfo datatypes that give a "hint" and store the results respectively.

Each website usually has multiple potential IP addresses, so to create and connect the socket, the program loops through the link list that points to the alternatives and uses the first option that functions.

After the socket connection is established a correctly formatted http request is written to the socket file descriptor (sockfd). As the response is read, the end of the http header is located, and the content of the body of the response is written to STDOUT.

Installation

All .h and .c files are contained in the inc/ and src/ directories. The Makefile is located in the project/ directory.

List of required .h files: format_url.h header.h helper.h memory.h tokenize.h

List of required .c files: format_url.c helper.c memory.c my_curl.c tokenize.c

> make my_curl

Usage

Usage is simple as functionality is limited. Initiate the function and provide a url address as the parameter:

./my_curl <url>

The Core Team

Rebecca Whipple Silverstein

Made at Qwasar SV -- Software Engineering School

my_curl's People

Contributors

rswhipple avatar

Watchers

 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.