×

注意!页面内容来自https://www.geeksforgeeks.org/html/what-is-http/,本站不储存任何内容,为了更好的阅读体验进行在线解析,若有广告出现,请及时反馈。若您觉得侵犯了您的利益,请通知我们进行删除,然后访问 原网页

<> .wrapper { flex-direction: column !important; } /* spinner css */ @keyframes spinner { to {transform: rotate(360deg);} } .spinner:before { content: ''; box-sizing: border-box; position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin-top: -10px; margin-left: -10px; border-radius: 50%; border: 2px solid #ccc; border-top-color: #000; animation: spinner .6s linear infinite; } .report-loader{ position: relative; } .report-loader.spinner{ margin-left: 16px; } .badges{ display: flex; align-items: center; position: relative; } .badges .gfg-badge-icon.md::after{ transform: scale(0.25); position:relative; top: 2px; left: -2px; } .sep{ margin: 0px 5px; font-size: 20px; color: var(--badge-name-color); } .pub-count{ font-size: 14px; font-family: var(--font-secondary); } .badge-details{ display:none; } .badges{ cursor: pointer; position: relative; /* width: 0px; height: 20px; top: -32px; */ } .badge-icon{ display: flex; align-items: center; } .badge-content{ margin-left: 9px; } .badge-name{ color: var(--badge-nam-color); font-weight: 600; font-size: 16px; text-transform: capitalize; } .badge-data{ color: #A5A4A4; font-size: 10px; } .badges:hover .badge-details{ display: block; background: var(--badge-bg); padding: 10px 18px 10px 18px; position: absolute; width: 175px; top: -10px; z-index: 10; left: 112%; box-shadow: rgb(100 100 111 / 20%) 0px 7px 29px 0px; border-radius: 5px; /* transform-origin: top right; */ } .badge-details::before { content: ""; position: absolute; transform: rotate(90deg); /* transform-origin: right; */ left: -6px; top: 50%; margin-left: -17px; border-width: 12px; border-: solid; border-color: var(--badge-bg) transparent transparent transparent; margin-top: -12px; } .badge-icon .icon{ border: 1px solid var(--icon-border-color); padding: 4px 3px; border-radius: 4px; width: 22px; height: 24px; position: relative; } .b-icon-pos{ position: relative; top: -34px; left: -34px; } /* article viewer */ .article--viewer .a-wrapper{ margin-top: 0px !important; } .content{ padding-top: 10px !important; } .u-name{ font-size: 14px; } .article--viewer_content .a-wrapper .content{ padding-bottom: 10px !important; } .likeTooltipBottom{ font-size: 14px; } @media (max-width: 434px) { .article-buttons.show-bg{ margin-top: 56px !important; } } @media (max-width: 730px), ((min-width: 992px) and (max-width:1100px)) { .article--viewer .media{ position: relative; } .article--viewer .media{ margin-bottom: 0px !important; } .badges:hover .badge-details{ top: -56px; left: 62px; } .badge-details::before{ transform: rotate(0deg); left: 10%; top: 117%; } .article-buttons.show-bg{ margin-top: 22px; top: 0px !important; } } @media ((min-width:731px) and (max-width:1223px)) { .article-buttons.show-bg{ top: 18px; } } @media ((min-width:993px) and (max-width:1190px)) { .article--viewer .media{ position: relative; } .article--viewer .media{ margin-bottom: 25px !important; } } <> .openInApp{ display: none; bottom: 0px; width: 100%; position: fixed; z-index: 1025; opacity: 0.93; } .openInAppLink{ height: 44px; background: var(--color-gfg); font-weight: bold; display: block; text-align: center; padding: 12px; font-size: large; } .openInAppLink.openInAppLink:hover.openInAppLink:active.openInAppLink:visited.openInAppLink:focus { text-decoration:none; }

Hypertext Transfer Protocol - HTTP

Last Updated : 16 Oct2025
Comments
Improve
Suggest changes
12 Likes
Like
Report

HTTP (Hypertext Transfer Protocol) is a fundamental protocol of the Internetenabling the transfer of data between a client and a server. It is the foundation of data communication for the World Wide Web. HTTP provides a standard between a web browser and a web server to establish communication. It is a set of rules for transferring data from one computer to another.

Screenshot-2023-05-29-102548
HTTP Connection

Note: Data such as textimages and other multimedia files are shared on the World Wide Web. Whenever a web user opens their web browserthe user indirectly uses HTTP. It is an application protocol that is used for distributedcollaborativehypermedia information systems.

Features

  • Stateless: Each request is independent and the server doesn't retain previous interactions' information.
  • Text-Based: Messages are in plain textmaking them readable and debuggable.
  • Client-Server Model: Follows a client-server architecture for requesting and serving resources.
  • Request-Response: Operates on a request-response cycle between clients and servers.
  • Request Methods: Supports various methods like GETPOSTPUTDELETE for different actions on resources.

Note: It was renamed as Hyper-Text Transfer Protocol QUIC (HTTP/3) and developed by Google.

Methods of HTTP

  • GET: Used to retrieve data from a specified resource. It should have no side effects and is commonly used for fetching web pagesimagesetc.
  • POST: Used to submit data to be processed by a specified resource. It is suitable for form submissionsfile uploads and creating new resources.
  • PUT: Used to update or create a resource on the server. It replaces the entire resource with the data provided in the request body.
  • PATCH: Similar to PUT but used for partial modifications to a resource. It updates specific fields of a resource rather than replacing the entire resource.
  • DELETE: Used to remove a specified resource from the server.
  • HEAD: Similar to GET but retrieves only the response headersuseful for checking resource properties without transferring the full content.
  • OPTIONS: Used to retrieve the communication options available for a resourceincluding supported methods and headers.
  • TRACE: Used for debugging purposes to echo the received request back to the clientthough it's rarely used due to security concerns.
  • CONNECT: Used to establish a tunnel to the server through an HTTP proxycommonly used for SSL/TLS connections.

HTTP Request/Response:

HTTP is a request-response protocolwhich means that for every request sent by a client (typically a web browser)the server responds with a corresponding response. The basic flow of an HTTP request-response cycle is as follows:

  • Client sends an HTTP request: The client (usually a web browser) initiates the process by sending an HTTP request to the server. This request includes a request method (GETPOSTPUTDELETEetc.)the target URI (Uniform Resource Identifiere.g.a URL)headers and an optional request body.
  • Server processes the request: The server receives the request and processes it based on the requested method and resource. This may involve retrieving data from a databaseexecuting server-side scripts or performing other operations.
  • Server sends an HTTP response: After processing the requestthe server sends an HTTP response back to the client. The response includes a status code (e.g.200 OK404 Not Found)response headers and an optional response body containing the requested data or content.
  • Client processes the response: The client receives the server's response and processes it accordingly. For exampleif the response contains an HTML pagethe browser will render and display it. If it's an image or other media filethe browser will display or handle it appropriately.
http_request
HTTP Request/Response

HTTP Request Circle

This table explains how HTTP requests work when you visit a webpage and what happens behind the scenes. Here’s a breakdown of the process:

Requested ResourceResource TypeServer Response
HTML PageHTMLServer sends HTML file
Style Sheet (CSS)CSSServer sends CSS file
Image (JPG)Image (JPG)Server sends JPG image
JavaScript CodeJavaScript (JS)Server sends JS file
Data (XML or JSON)DataServer sends XML/JSON data
  1. Requested Resource: This is the type of content you're asking the server to send you. For exampleit could be an HTML pagea sheet (CSS)an image or JavaScript code.
  2. Resource Type: This tells the server what kind of file or data you need. For examplean HTML page would be of type HTMLa sheet is CSSan image would be an image type (like JPG)JavaScript code is of type JS and data could be in formats like XML or JSON.
  3. Server Response: After receiving the requestthe server sends back the correct file or data based on the request. For exampleif you requested an HTML pagethe server sends back the HTML file or if you requested an imagethe server sends back the image file.

Examples for each request

  • HTML Page: If you want a webpagethe server sends back the HTML content.
  • CSS: For styling a webpagethe server sends the CSS file.
  • Image: If you ask for a picture (like a JPG)the server sends the image.
  • JavaScript: If you need functionality for the pagethe server sends the JS code.
  • Data: If you're looking for specific data (like in XML or JSON format)the server sends that data back.

Note: The "HTTP Request Circle" is just showing how a web browser requests different kinds of resources from a server and the server responds by sending the corresponding files or data.

Overview of HTTP Request and Response Components

ConceptDescription
HTTP Request HeadersText information in key-value pairs sent with every HTTP requestconveying details such as client's browserrequested data and more.
HTTP Request BodyContains data being submitted to the web serversuch as form inputsauthentication details or other payload data.
HTTP ResponseSent by the server in answer to an HTTP requestconsisting of an HTTP status coderesponse headers and optional response body.
HTTP Status Codes3-digit codes indicating the outcome of an HTTP requestcategorized into 1xx (Informational)2xx (Success)3xx (Redirection)4xx (Client Error) and 5xx (Server Error) blocks.
HTTP Response HeadersProvide important information like data formatlanguage and content type in the responsehelping clients interpret the data correctly.
HTTP Response BodyContains the requested information sent by the serversuch as HTML content for webpagesJSON data or other data based on the client's request.

History of HTTP

  • Tim Berners-Lee and his team at CERN are indeed credited with inventing the original HTTP protocol.
  • HTTP version 0.9 was the initial version introduced in 1991.
  • HTTP version 1.0 followed in 1996 with the introduction of RFC 1945.
  • HTTP version 1.1 was introduced in January 1997 with RFC 2068later refined in RFC 2616 in June 1999.
  • HTTP version 2.0 was specified in RFC 7540 and published on May 142015.
  • HTTP version 3.0also known as HTTP/3is based on the QUIC protocol and is designed to improve web performance.

Advantages

  • Platform independence: Works on any operating system
  • Compatibility: Compatible with various protocols and technologies
  • Efficiency: Optimized for performance
  • Security: Supports encryption for secure data transfer

Disadvantages

  • Lack of security: Vulnerable to attacks like man in the middle
  • Performance issues: Can be slow for large data transfers
  • Statelessness: Requires additional mechanisms for maintaining state

Article Tags :

Explore

<> .article--container_content{ align-items: unset !important; } .sideBar { position: sticky !important; } .gfg-icon_switch::after { background-position: -40px -281px !important; } .gfg-icon_transaction::after { background-position: -40px -321px !important; } .header-main__profile.selected+.mega-dropdown{ width: 225px !important; } #courses-container .course-price{ display:none; } /* .side--container_wscard .card-content .content .meta:empty.practiceBannerFromPlugin{ display:none !important; } */ .side--container_wscard .card-content .content .meta{ display:block !important; } .side--container_wscard .card-content .content .meta p{ background-color: rgba(254212910.6); font-size: 10pt; font-weight: bold; display: inline-block; color: var(--color-black); margin-top: 15px; padding: 0px 5px; } #try-it{ display:initial !important; } #try-it .try-it-div{ line-height: 34px; } .gfg-icon_dark-mode::after { background-position: -40px -680px; } .side--container_wscard .head{ font-size: 14px !important; } .nineDot-menu.gfg-icon_ndot{ display: none; } #text-15{ flex-direction: column; } .mtq_correct_marker.mtq_wrong_marker{ display: none; } .sidebar_wrapper > :last-child{ margin: unset !important; margin-left: 5px !important; margin-top: 20px !important; top: 70px !important; } .darkMode-wrap{ bottom:1% !important; } #secondary .textwidget{ margin-left: auto; margin-right: 0; text-align: right; } #secondary .widget_text:last-child{ top: 70px !important; } @media(max-width:768px){ #scrollTopBtn{ display:none !important; } } .rightbar_loggedin_promo_cta{ display:flex; cursor:pointer; margin-bottom:20px; } /* Carousel Ad CSS dont remove or change without permission */ .ads-carousel-container { width: 300px; overflow: hidden; position: relative; min-width: 300px; max-width: 300px; } .ads-carousel-track { display: flex; transition: transform 0.5s ease-in-out; width: 900px; /* 3 slides * 300px */ } .ads-slide { min-width: 300px; max-width: 300px; max-height: 250px; margin-bottom: 10px; overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: bold; color: white; } /* ✅ Carousel dots container */ .carousel-dots { display: flex !important; justify-content: center; margin: 10px 0px; visibility: hidden; } .show-flex-ad { visibility: visible; } /* ✅ Each dot */ .dot { width: 6px; height: 6px; margin: 0 5px; border-radius: 50%; background-color: gray; transition: background-color 0.3s ease; } /* ✅ Active dot */ .dot.active { background-color: blue; }
<> .grecaptcha-badge { visibility: hidden !important; } .thank-you-message { height: 100%; display:flex; flex-direction: column; justify-content: center; align-items: center; } .thank-you-message-content { margin-top: 17px; font: 400 20px var(--font-secondary); color: var(--improve-modal-text); line-height: 180%; text-align: center; } .thank-you-message-content h2{ font-family: var(--font-secondary); } .all-footer-information{ width: 100% !important; height: fit-content; } .footer-wrapper_links-list{ margin-block-start: 0em !important; width: 16% !important; padding-inline-start: 18px !important; } .link-head{ margin-bottom: 0px; } .footer-wrapper_branding{ height: fit-content; } .footer-wrapper_branding-social{ height: fit-content; } .advertise-block{ display: block !important; } @media only screen and (max-width:1340px) { .footer-wrapper_links-list{ overflow-wrap: break-word; } } @media screen and (min-width: 991px) { .all-footer-information{ padding-left:15px; height: fit-content; } .footer-wrapper_branding-app{ display: flex !important; margin: 22px 0 0 20px; } } @media only screen and (max-width:980px) { .footer-wrapper_branding-address{ padding-top: 10px; } } @media (max-width: 750px) { .thank-you-message-content{ font-size: 14px; line-height: 170%; } } @media only screen and (max-width:991px) { .footer-wrapper_branding-app-wrapper{ display: block !important; margin: auto !important; max-height: none !important; } } @media (min-width: 991px) and (max-width: 1046px) { .footer-wrapper_branding-app-wrapper{ display: block !important; max-height: none !important; } .footer-wrapper_branding-app{ margin: 22px 0 0 6px !important; } } /* CSS variable meant to handle the dark and light mode icon for three 90 event in header courses dropdown */ :root{ --three90headericon : url('https://media.geeksforgeeks.org/auth-dashboard-uploads/three90daylogocompressed.svg'); --three90headericonposition : 0px -40px; --three90leftbarimggrid : url('https://media.geeksforgeeks.org/auth-dashboard-uploads/three90leftbarspritecompressed.svg'); --three90leftbarimgposition : -5px -55px; --three90leftbarbgcolour : #b3abd0; } body[data-dark-mode="true"]{ --three90leftbarimgposition : -6px 1px; --three90headericonposition : 0px 0px; --three90leftbarbgcolour: #8c82b9; } .three90leftbarimg{ margin-left: -5px; height: 30px; background-image: var(--three90leftbarimggrid); background-repeat: no-repeat; background-position: var(--three90leftbarimgposition); background-size: 212px; } .courseTabShimmer{ position: absolute; height: 110%; width: 0; opacity: .7; -webkit-animation: courseShimmer 2s cubic-bezier(0,0,.07,.61) infinite; animation: courseShimmer 2s cubic-bezier(0,0,.07,.61) infinite; box-shadow: 0 0 25px 5px #dddcdc; -webkit-transform: rotate(90deg); transform: rotate(90deg); padding:0px !important; border:unset !important; } @keyframes courseShimmer{ 0% { left: 0; } 55% { left: 100%; } 99% { left: 110%; } }
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 wordsmax Words Limit:1000

Thank You!

Your suggestions are valuable to us.

<> /* Temporary CSS for Three90 pop up modal (START)*/ .three90popup__container { width: 100vw; height: 100vh; position: fixed; top:0px; background: var(--job-tab-faded-background); z-index: 1024; display: flex; align-items: center; justify-content: center; } .three90modal__wrapper{ background-color: white; max-width: 350px; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; } .three90modal__message-container { display: flex; flex-direction: column; align-items: center; font-family: var(--font-primary); } .three90modal__subheading { margin-top: 20px; font-size: 22px; font-weight: 600; } .three90modal__text-message { margin-top: 20px; font-size: 15px; font-weight: 400; text-align: center; padding: 0 5px; } .three90__modal__button-wrapper { width: 100%; padding: 20px 0px; display: flex; justify-content: space-evenly; } .three90__modal__button-wrapper > button { width: 105px; height: 35px; border-radius: 13px; border:none; font-weight: 600; cursor: pointer; } #three90__modal-close-btn:hover { background-color: #cacbcd; } #three90__modal-explore-btn { background-color: #0a0727; color: white } @media screen and (max-width: 441px) { .three90modal__wrapper { max-width: 300px; } } /* Temporary CSS for Three90 pop up modal (END)*/
<> :root { --com-extra-icons-mobile-image: url(https://media.geeksforgeeks.org/auth-dashboard-uploads/Com-Extra-Icons13.svg); --write-experience-card-1: #ECF5F5; --write-experience-card-icon-1: #21898C; --write-experience-card-2: #EAF2F7; --write-experience-card-icon-2: #3079AC; --write-experience-card-3: #FDEFE6; --write-experience-card-icon-3: #F5A572; --write-experience-card-4: #F1F8F5; --write-experience-card-icon-4: #91C4AD; --write-experience-card-5: #EEE7FF; --write-experience-card-icon-5: #8B72C9; --write-experience-card-6: #F2F8E6; --write-experience-card-icon-6: #78C57F; --editor-button-text-color: #6E6E73; --write-modal-background: #fefefe; --experience-sidebar: #000; --left-bar-background: #FFFFFF; --write-redirect-container:#EAF2F7; --write-redirect-container-hover:#d6e7f2; } /* Dark Mode */ body[data-dark-mode="true"] { --write-modal-background: #161c23; --experience-sidebar: #000; --left-bar-background: #F0F3F5; } .popup-main { padding: 20px 18px 20px 18px; border-radius: 8px; } .popup-main .popup-heading { display: flex; align-items: center; color: #E9E9EA; margin-bottom: 10px; justify-content: space-between; } .popup-main .close-icon { background-image: var(--com-extra-icons-mobile-image);background-position: -15px -1651px;height: 22px;width: 22px;transform: scale(1); margin-bottom: 12px; cursor: pointer; } .popup-main .experience-card { color: #000; display: grid; grid-template-columns: repeat(21fr); gap: 16px; /* margin-bottom:10px; */ } .popup-main a:hover, .popup-main a:active, .popup-main a:visited { color: inherit; text-decoration: none; } .popup-main .exp-card1, .popup-main .exp-card2, .popup-main .exp-card3, .popup-main .exp-card4, .popup-main .exp-card5, .popup-main .exp-card6 { display: flex; align-items: center; border-radius: 10px; cursor: pointer; } .popup-main .exp-card1 .icon1, .popup-main .exp-card2 .icon2, .popup-main .exp-card3 .icon3, .popup-main .exp-card4 .icon4, .popup-main .exp-card5 .icon5, .popup-main .exp-card6 .icon6 { width: 80px; height: 80px; border-radius: 10px 0px 0px 10px; display: flex; align-items: center; justify-content: center; background: var(--write-experience-card-icon-1); } .popup-main .exp-card1 .icon1, .popup-main .exp-card2 .icon2, .popup-main .exp-card3 .icon3, .popup-main .exp-card4 .icon4, .popup-main .exp-card5 .icon5, .popup-main .exp-card6 .icon6 { width: 80px; height: 80px; border-radius: 10px 0px 0px 10px; display: flex; align-items: center; justify-content: center; } .popup-main .exp-card1 .icon1 { background: var(--write-experience-card-icon-1); } .popup-main .exp-card2 .icon2 { background: var(--write-experience-card-icon-2); } .popup-main .exp-card3 .icon3 { background: var(--write-experience-card-icon-3); } .popup-main .exp-card4 .icon4 { background: var(--write-experience-card-icon-4); } .popup-main .exp-card5 .icon5 { background: var(--write-experience-card-icon-5); } .popup-main .exp-card6 .icon6 { background: var(--write-experience-card-icon-6); } .popup-main .exp-card6 .icon6-image { background-image: url(https://media.geeksforgeeks.org/auth-dashboard-uploads/compass.svg); width: 46px; height: 30px; background-size: 30px; background-repeat: no-repeat; background-position: center; } .popup-main .exp-card1 .icon1-image { background-image: var(--com-extra-icons-mobile-image); width: 46px; height: 28px; background-position: -4px -812px; } .popup-main .exp-card2 .icon2-image { background-image: var(--com-extra-icons-mobile-image); width: 46px; height: 28px; background-position: -4px -888px; } .popup-main .exp-card3 .icon3-image { background-image: var(--com-extra-icons-mobile-image); width: 46px; height: 28px; background-position: -4px -848px; } .popup-main .exp-card4 .icon4-image { background-image: url(https://media.geeksforgeeks.org/auth-dashboard-uploads/competitive.svg); width: 46px; height: 30px; background-size: 30px; background-repeat: no-repeat; background-position: center; } .popup-main .exp-card5 .icon5-image { background-image: var(--com-extra-icons-mobile-image); width: 46px; height: 33px; background-position: -4px -1217px; } .popup-main .exp-card1 .exp-card1-text, .popup-main .exp-card2 .exp-card2-text, .popup-main .exp-card3 .exp-card3-text, .popup-main .exp-card4 .exp-card4-text, .popup-main .exp-card5 .exp-card5-text, .popup-main .exp-card6 .exp-card6-text { display: flex; align-items: center; border-radius: 0px 10px 10px 0px; height: 80px; width: calc(100% - 80px); } .popup-main .exp-card1 { justify-content: flex-start; background: var(--write-experience-card-1); } .popup-main .exp-card2 { justify-content: flex-start; background: var(--write-experience-card-2); } .popup-main .exp-card3 { justify-content: flex-start; background: var(--write-experience-card-3); } .popup-main .exp-card4 { justify-content: flex-start; background: var(--write-experience-card-4); } .popup-main .exp-card5 { justify-content: flex-start; background: var(--write-experience-card-5); } .popup-main .exp-card6 { justify-content: flex-start; background: var(--write-experience-card-6); } .popup-main span { font-family: var(--font-primary); font-size: 14px; font-: normal; font-weight: 500; line-height: normal; padding-left: 5px; padding-right: 5px; } #popup { display: none; background-color: var(--write-modal-background); padding: 20px; text-align: center; position: fixed; top: 50%; left: 50%; transform: translate(-50%-50%); z-index: 1026; width: min(650pxcalc(100% - 20px)); } .link-container-write{ display:flex; flex-direction:column; } .link-container-write > a { margin:7px 0px; } .phrase__container{ color:var(--color-gfg); border-radius: 6px; width: 100%; background-color:var(--write-redirect-container); padding: 15px; text-align: justify; font-size:14px; } .phrase__container:hover { color:var(--color-gfg) !important; background-color:var(--write-redirect-container-hover); }