Giter Site home page Giter Site logo

vladutmargineanu / http-rest-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 216 KB

Homework for the Communication Protocols course @ ACS, UPB 2018

License: MIT License

Makefile 0.92% C 99.08%
http-rest-api json-parser json communication-protocols-course protocols client-server

http-rest-api's Introduction

HTTP-REST-API

Homework for the Communication Protocols course @ ACS, UPB 2018

Algorithm

In arhiva temei am urmatoarele fisiere: client.c, helpers.c, helpers.h si Makefile. Stim ca REST API are la baza modelul client-server, unde serverul este implementat ca un black box, scopul temei fiind sa intelegem cum functioneaza protocolul HTTP. In client.c am facut primul request si am creat cate o functie care sa rezolve fiecare task in parte cerute in enunt. Am folosit parserul din libjson-c-dev care mi-a parsat raspunsul pe baza de tokeni. Am folosit biblioteci externe pentru parsarea si crearea de structuri JSON. Stim din enunt ca IP-ul serverului este: 185.118.200.35, iar portul este: 8081. Pentru parsare am folosit biblioteca de parsare JSON "#include<json-c/json.h>". Codul l-am scris sa fie compatibil cu standardul ANSI C pentru parsarea unui document JSON simplu. Pentru folosirea bibliotecii, am rulat urmatoarea comanda pe linux (instalam biblioteca pentru parsare): [1] sudo apt install libjson-c-dev Dupa ce am obtinut raspunsurile venite de la server cu structura clasica si le-am parsat corespunzator, m-am folosit de functiile compute_get_request si compute_post_request pentru a-mi creea cererile. Dupa ce am creeat cererile, daca o cerere a fost efectuată corect, serverul va intoarce un obiect de tip JSON, cu mai multe câmpuri, din care obtinem enuntul etapei urmatoare. De asemenea am mai folosit functia hostname_to_ip care imi returneaza ip-ul unei adrese pe care o primeste. Pentru a putea folosi datele din răspunsul serverului, am utilizat o bibliotecă de parsare de JSON pentru extragerea datelor.

Resurse internet pentru biblioteca de parsare JSON "#include<json-c/json.h>" am gasit la adresa urmatoare: [2] https://progur.com/2018/12/how-to-parse-json-in-c.html

http-rest-api's People

Contributors

vladutmargineanu 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.