UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR
PAKISTAN
Main Campus
Computational
Intelligence
ASSIGNMENT # 02
Submitted By
Registration No: 21PWBCS0881
Name:
Abdullah
Date: 30/10/2024
Semester: 7th CSIT (B)
Submitted To Sir Hamas Ur
Rehman
DEPARTMENT OF COMPUTER SCIENCE & IT
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR, PAKISTAN
Assignment: 02 Screenshots
QUESTION 1:
Get Menu list:
Using http method get to display list
Using route /menulist for display
Task 1:
Add item in list
Adding item in list by using post method through item id as the
code is given in file
And using docs for doing task
Here is the list after adding item
Task 2:
Delete Item from list
Deleting item from list, through id loop
First go to route of menu list then through id delete item
Using http method delete
Use docs
Here’s the updated item lists after deleting item
Task 3:
Updating item in list
Updating the price of a specific item by id
Like item 4 price will be changed to 1000
Using put method for this purpose
Then using docs for updating
List after updating the price of item id 4
Question: 02
What are HTTP status codes and why is sending just a response
body not enough without including proper status codes?
Answer:
An HTTP status code is a standardized three-digit number sent by a server in
response to a client's HTTP request, indicating the status of that request. Status
codes help the client understand if the request was successful, redirected, resulted
in a client or server error, or requires further action. They are divided into
categories:
1xx (Informational): Request received, processing continues.
2xx (Success): Request successfully processed.
3xx (Redirection): Further action is required to complete the request.
4xx (Client Error): Error due to client's request.
5xx (Server Error): Error on the server's side while processing the request.
Each category and code provides specific context, improving communication
between clients and servers in web applications.
Why HTTP Status Codes Are Important:
1. Client Understanding: Status codes provide clients with clear feedback on
request success or failure.
2. Error Handling: They enable clients to handle errors effectively by
identifying specific issues.
3. Optimization and Redirection: Codes like 304 and 301 guide caching and
redirection, optimizing resources.
4. API Design and Testing: Status codes allow standardized, predictable
responses for testing and API functionality.
5. Security and Compliance: Codes like 401 and 403 ensure secure,
compliant access control and permissions.
Why a Response Body Alone is not enough:
1. Ambiguity in Client: Without status codes, clients may misinterpret the
response’s success or failure.
2. Non-Standardized Responses: Relying solely on response bodies leads to
inconsistent client-server interactions.
3. Lack of Automation Support: Testing and monitoring tools depend on
status codes for reliable validation and error handling.