HTTP GET

Back to HTTP Tutorial Index

An HTTP GET request sent by a browser looks something like this:

GET /stocks/charts/HD/home-depot/operating-income HTTP/1.1
Host: www.macrotrends.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Sec-GPC: 1

A GET request sent by PostMan looks something like this:

GET /stocks/charts/HD/home-depot/operating-income HTTP/1.1
User-Agent: PostmanRuntime/7.29.0
Accept: */*
Cache-Control: no-cache
Postman-Token: a2dbaa09-91b5-4ff2-96b6-41b5313591a6
Host: www.macrotrends.net
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

About HTTP GET Requests

  • The 1st line is the HTTP start line. It contains the HTTP verb ("GET"), followed by the path part of the URL, and finally the HTTP protocol version.
  • Following the start line, we have the request header which is a standard MIME header. A blank line follows the MIME header.
  • Unlike POST requests (See HTTP POST Request), GET requests do not have a request body.
  • There is no need for Content-Length or Content-Type headers because the request has no body. There is no content to have a type and the Content-Length would always be 0.
  • A GET request is what's sent when you type or copy/paste a URL into the browser's address bar and press RETURN. You are getting the content at the given URL.
  • A browser adds various headers to tell the server the request is coming from an interactive browsing session.
  • Postman or applications sending REST API GET's will not include browser-specific headers. Postman adds User-Agent and Postman-Token which are not necessary.
  • The Host header is the domain part of the URL. In the above example, the URL would be "https://example.com/stocks/charts/HD/home-depot/operating-income". Chilkat always automatically adds the Host header.
  • The Accept and Accept-Encoding headers are automatically added by Chilkat, but can be changed by your app or suppressed. They tell the server information about what kinds of responses are acceptable.
  • You can generate source code from a raw HTTP request using Chilkat's online tool at https://tools.chilkat.io/httpRequestToCode.

CURL

A CURL statement to send the above HTTP request is shown here. You can generate source code from a CURL statement using Chilkat's online tool at https://tools.chilkat.io/curlHttp

curl -X GET https://example.com/stocks/charts/HD/home-depot/operating-income \
  -H "User-Agent: PostmanRuntime/7.29.0" \
  -H "Accept: */*" \
  -H "Cache-Control: no-cache" \
  -H "Postman-Token: a2dbaa09-91b5-4ff2-96b6-41b5313591a6" \
  -H "Host: www.macrotrends.net" \
  -H "Accept-Encoding: gzip, deflate, br" \
  -H "Connection: keep-alive"

Chilkat Examples Implementing the Above HTTP GET

You can use Chilkat's online tool at https://tools.chilkat.io/curlHttp to generate code from a CURL statement. Copy/paste the CURL statement into the online tool, choose your programming language, and click the "Generate Code" button.