Understanding HTTP Messages

Understanding HTTP Messages

In our quest to understand API testing, the first step would be to understand the general protocol used by client and server side of an application to communicate, which in API automation we would try to automate.

This post is a summary of a discussion from the video below. 


Sending an email is like posting a letter

The goal here would be to translate the concepts with daily life examples to understand client server communication easily. Transmitting of data from client to server is pretty much like sending a letter from one postal address to another, only it takes days instead of milliseconds!

The steps in both are very much the same, except the way of doing them. The takeaway here is what the main requirements for sending a letter are the same for what is needed to send an email, sender and receiver details and transmission details needed.

Communication layers

In our example, when Bob sends his mail, the courier company would seal the letter in their envelope along with some of their transportation data like from / To addresses and a tracking number.

All digital communications follow a similar model called the OSI Layers (https://searchnetworking.techtarget.com/definition/OSI) model. The actual message to be sent from sender to receiver is encapsulated with headers and additional transmission information. There can be different message types and header configurations, all explaining how to send and display the message to the receiver.

Constructing an HTTP Request

There are few main areas of an HTTP request, we’ll look into each of them and find out how they help in forming a request.

‘Request Methods’ refers to the different type of HTTP messages used for different purposes. Mostly commonly used are GET and POST messages.

Headers include communication related data, session IDs, client type, body data type are some very common ones. In some cases (e.g. for GET messages) the request need to be made is part of the header. A client side requesting a specific record will add the request in the header of a GET message.

The ‘Body’ includes data to send the server side. A common example would be adding data to the database. In our example when Bob sends the email, the text of his email goes in the body section of the message. There are different formats in which this data can be encoded.

HTTP Request and Response

When Bob sent the email, an ‘HTTP request’ was sent. To confirm the transmission an ‘HTTP response’ will be sent back from the server to the client.

While performing API automation, the tests would construct an HTTP request and assert the corresponding response received. An understanding of the response is therefore critical. In some cases further requests might be needed to confirm if all the data expected is saved and retrieved properly.

This is a re-post from 'The Automation Blog Book ' - TABB. The original post and video can be viewed here and here.


要查看或添加评论,请登录

Ali Khalid的更多文章

  • Intro to Data Analytics & Quality Workshop

    Intro to Data Analytics & Quality Workshop

    The WHY Getting familiar with the basics of data analytics can be a daunting task. With so many buzz words flying…

    15 条评论
  • Testing AI based systems - QA&TEST 2020

    Testing AI based systems - QA&TEST 2020

    This year’s QA&TEST conference 2020 was another great addition. While planning the event there were discussions on if…

    4 条评论
  • Tips on Working From Home

    Tips on Working From Home

    For a while I’ve worked from home off and on. Even while not working from home.

    7 条评论
  • QA&Test Conference 2019

    QA&Test Conference 2019

    Having a background in embedded systems, I was contacted by the QA&TEST organizers to speak at their conference in…

    5 条评论
  • My Experience at the Test Leadership Congress

    My Experience at the Test Leadership Congress

    Two weeks ago I went to the Test Leadership Congress conference in NYC, absolutely loved the content and speakers. It…

  • 900 miles to seek knowledge

    900 miles to seek knowledge

    From the past few years whenever I travel, I usually try to meet people I know from social media if I get a chance…

    7 条评论
  • The Art of Resigning

    The Art of Resigning

    When I switched jobs recently, it was a very surreal experience. The stakes were high and there was a lot of ‘be…

    12 条评论
  • Intro to Pace Layered Application Strategy

    Intro to Pace Layered Application Strategy

    Just like products across different industries are not the same, similarly software products are not the same either…

  • Lessons Learned from 2018

    Lessons Learned from 2018

    Looking back at the year I thought to jot down the most important things I learned and share with the community. People…

    11 条评论
  • The passionate knowledge worker

    The passionate knowledge worker

    One of the biggest problem employers have is they are not able to find / or get their team passionate about what they…

社区洞察

其他会员也浏览了