Networking/http Flashcards
What is a client?
A piece of computer hardware or software that accesses a service made available by a server.
What is a server?
A piece of computer hardware or software (computer program) that provides functionality for other programs or devices, called “clients”
Which HTTP method does a browser issue to a web server when you visit a URL?
GET method
What three things are on the start-line of an HTTP request message?
- An HTTP Method (GET, PUT, POST, HEAD, OPTIONS… etc)
- The request target, usually a URL
- The HTTP version, which defines the structure of the remaining message acting as an indication of the expected version to use for the response
What three things are on the start-line of an HTTP response message?
- The protocol version, usually HTTP/1.1.
- A status code, indicating success or failure of the request.
- A status text. A brief, purely informational, textual description of the status code to help a human understand the HTTP message.
What are HTTP headers?
HTTP headers let the client and the server pass additional information with an HTTP request or response
HTTP headers specify the request, or describing the body included in the message. Additional information about the request itself.
Is a body required for a valid HTTP request or response message?
A body is optional, though frequent for responses.
What is the significance of an HTTP request’s method?
Request methods indicate the desired action to be performed for a given resource.
The request method is about expressing intent but it is arbitrary - it is up to the server to provide a response and it does not have to related to the request.
What does fetch( ) return?
A Promise that resolves to a Response object.
What is the default request method used by fetch( )?
GET
How do you specify the request method (GET, POST, etc.) when calling fetch?
By adding a method property to the options object passed in as the second argument to the request. (the first being the request target)
e.g: fetch( ‘https://pokeapi.co/api/v2/pokemon/pikachu’, { method: ‘GET’
} )
What does response.json do?
The json( ) method of the body mixin take a Response stream and reads it to completion and pareses the body text as JSON