This project implements a command-line HTTP client in C that interacts with a RESTful web service for managing users, movies, and movie collections. The client uses POSIX sockets to send HTTP requests, handles session cookies and JWT-based authentication, and parses JSON payloads.
- Establish connection with the server.
- Read user command from stdin and dispatch to the corresponding handler.
- Execute operations until the
exitcommand is received. - Close the connection and free allocated resources.
- login_admin: Prompt for admin credentials, send
POST /api/v1/tema/admin/login, store session cookie on success. - add_user: Read new user details, send
POST /api/v1/tema/admin/userswith session cookie. - get_users: Send
GET /api/v1/tema/admin/userswith session cookie to list all users. - delete_user: Prompt for username, send
DELETE /api/v1/tema/admin/users/:username. - logout_admin: Send
GET /api/v1/tema/admin/logout, clear session cookie.
- login: Prompt for user credentials, send
POST /api/v1/tema/user/login, store session cookie. - get_access: Send
GET /api/v1/tema/library/accesswith session cookie, store returned JWT. - logout: Send
GET /api/v1/tema/user/logout, clear session cookie and JWT.
- get_movies:
GET /api/v1/tema/library/movieswith session cookie and JWT. - add_movie: Prompt for title, year, description, rating; send
POST /api/v1/tema/library/movies. - get_movie: Prompt for movie ID;
GET /api/v1/tema/library/movies/:movieId. - update_movie: Prompt for ID and updated details;
PUT /api/v1/tema/library/movies/:movieId. - delete_movie: Prompt for movie ID;
DELETE /api/v1/tema/library/movies/:movieId.
- get_collections:
GET /api/v1/tema/library/collectionsto list collections. - add_collection: Create new collection via
POST /api/v1/tema/library/collections, then add movies. - delete_collection: Remove collection with
DELETE /api/v1/tema/library/collections/:collectionId. - add_movie_to_collection: Prompt for collection ID and movie ID;
POST /api/v1/tema/library/collections/:collectionId. - delete_movie_from_collection: Prompt for collection ID and movie ID;
DELETE /api/v1/tema/library/collections/:collectionId/:movieId.
- contains_spaces: Check for spaces in usernames or passwords.
- check_for_error_and_print: Scan server response for “error” and display details.
- get_session_cookie: Extract session cookie from server response.
- get_jwt: Extract JWT token from server response.
- parse_and_print_users: Extract and display user list from JSON.
- parse_and_print_movies: Extract and display movie list from JSON.
- parse_and_print_movie: Extract and display a single movie’s details.
- parse_and_print_collections_simple: Extract and display collection IDs and titles.
- parse_and_print_collection_details: Extract and display full collection details.
- compute_delete_request: Build DELETE requests.
- compute_put_request: Build PUT requests.
All compute* functions accept an optional JWT parameter for secure calls._
- GCC or compatible C compiler
- POSIX-compliant environment (Linux, macOS)