‫Hello, my friends, and welcome back.
‫In this video, we'll talk about the Http requests and responses.
‫So an Http client sends an Http request to a server in form of a request message.
‫The request method indicates a method to be performed on the resources identified by a given request.
‫Uri.
‫This method is is included inside the request message.
‫So there are a lot of methods, but I want to focus on two main methods that we're going to use the
‫get and the post.
‫The get method in the Http request is used to retrieve information from the given server using a given
‫Uri.
‫Requests using get should only retrieve data and should have no other effect on the data.
‫While the post method that it's included inside the Http request is used to send data to the server.
‫For example customer information file upload et-cetera using HTML forms.
‫So.
‫When you need to retrieve data, you should use get.
‫When you need to post data, When you need to upload data to the server, you need to use post method.
‫When the server answers you answer the client.
‫Answer the application.
‫An Http response is made by the server to a client.
‫The aim of the response is to provide the client with the resources that it's requested or inform the
‫client that the action is requested, that it is requested, has been carried out, or else to inform
‫the client that an error occurred in processing its request.
‫So the server either will answer you with your answer or with for your question.
‫Or were request to be carried out or to tell you that your request, your question is not valid and
‫it's not performed.
‫An Http response contains a status line.
‫A series of Http headers or header fields.
‫A message body which is usually needed.
‫So when the server answers, you will be answering you in a response that contains a status line series
‫of Http headers and the message body.
‫But we're going to focus on an important thing, which is in a status line.
‫It's called Http response codes.
‫I'm not here to teach you the networking.
‫I'm here to teach you the basic things that we're going to use in networking in Android.
‫So.
‫We are interested in the Http response codes.
‫The status line, which is included in the Http response is the first line in the response message.
‫It contains a status code which which is a three digit number indicating the result of the request.
‫So how to tell how the server tells you that your your request is success or redirected or there is
‫an error or the server has an error, you will be getting an Http response code which is in form of
‫three digit number 200 will indicate success or.
‫Okay, so your request is good and success 300 301 Permanent redirect 302 Temporary redirect 304 not
‫modified.
‫This is the response from the server.
‫If the server answered you by 401 an unauthorized error 403 forbidden 404 not found 405 method not allowed
‫500 so 5501 not implemented.
‫502 Bad gateway 503 server service unavailable.
‫504 Gateway timeout.
‫These are the main Http status codes that we're going to see and deal with in.