Skip to main content

Study Guide 170



HTTP

  • Describe what HTTP is and the role of the request and the response.
    • HTTP is just a text sent over the internet with a set of rules that governs how computer communicates with each other. It follows a model whereby a client makes a request and then wait for a response from a server. HTTP itself doesn't transmit data, it depends on TCP/IP protocol to get request/response from one machine to another. 
  • What are the components of an HTTP request and an HTTP response?
    • HTTP request and response has a header and body. 
    • HTTP response will contain status code ( 200 OK)  and headers which is a metadata that contain information for content-type (text/html),  Content-Encoding:gzip (type of file compression), server (name of the server), Location (new resource location for redirects) and a HTTP body 
    • HTTP request header contain information on HTTP method (GET/POST) , path and parameter to allow server to know how to find information, along with optional headers that include info on  user-agent(chrome, mozilla), accept-language: en, cookie, connection:keep alive and optional HTTP body. 
    • HTTP body contain the main message of the HTTP , typically they are HTML, CSS, JAVASCRIPT, image or audio etc. 
    • Common types of status code
      • 200 ok - the request is served fine
      • 302 found - redirect the url to a new location via the header's 'Location' parameter
      • 404 not found - page cannot be found
      • 500 Internal server error - something wrong in the server code. 
  • Identify the components of a URL. Construct a URL that contains a few params and values.
    • https://example.com:88/files?due=today&due=tomorrow
    • https is the protocol or the scheme, it tells client how to access the resources
    • example.com is the host , where the resources is hosted/located
    • 88 is the port number. 
    • /files is the path, or where the resources is located locally
    • ?due=today&due=tomorrow , this is query string, due is parameter name and today is parameter value, & is used to delimit second parameter string.
  • Explain the difference between GET and POST, and know when to choose each.
    • GET is used to retrieve information from a server while POST is used to write/manipulate information in a server
    • GET can pass information to the server via query string. Query string has maximum length and are visible to user (password can't be sent via query string).
    • POST request will store the information to be passed to server in the HTTP body. There is no size limit to the information to be sent. It is still not secured unless it is encrypted. 
  • What is the difference between client-side and server-side code? For each file in a Sinatra project, be able to say which it is.

Web

  • How does an HTML form element interact with the server-side code that processes it.
  • Why is user-entered content a security risk? Be aware of how to mitigate this risk.
    • Also known as cross-site scripting. A user could write a malicious javascript that jeopardize the site to a forum comment for example. Typical way to mitigate this risk is to sanitize user's input by removing <script> tag or dissallowing JS / HTML altogether for safer format like Markdown. Or , escape all user input data when displaying it.

Sinatra

  • Start a new Sinatra project and write simple routes to handle requests.
  • What are the benefits of using view templates? Be able to use an ERB template in a Sinatra route.
  • What is the session? Where it is stored? How it is used?
    • A session is a way that web application can maintain some states/history in a stateless HTTP environment. It maintain this by exchanging a unique session ID. A common session  ID is a cookie. The cookie is set by the server the first time a client visits a website. Then, the client will send the cookies back and forth with server. The server will use the cookies to retrieve session data stored in its database to serve up the webpages. 
  • Write a view helper and use it within a view template.
  • Explain how redirection works and why it would be needed in a web application.

Comments

Popular posts from this blog

Problem Solving - Refactored

I am going to outline how I approach problem solving. The relative importance and the amount of effort/time required for each is stated as a percentage beside each topic. I borrowed some idea from George Polya's How to Solve It Thoroughly Understand the Problem (30%) When encountering hard problem , you need to deeply understand the problem at hand. Take a paper and list down all known facts and data and what the question is trying to find. Sketch out the problem if applicable. Visualize the problem in your head. A lot of times, we only have to understand the problem well, then the solution will obvious. Have a Plan (20%) You need to have an outline of how you are going to tackle the problem. You need to have a logical pathway that will ultimate produce outcome (nothing to do with coding syntax yet). Without a plan, you are just randomly poking around and got lucky. No hard problem ever gets solved without a plan. Plan using pseudo-code, pen & paper or flowchart. Use wh

My Burnout Experience

I want to share with you my experience of burning out. After registering with Launch School, I am extremely excited about my programming journey. I studied for 10 to 12 hours a day, memorizing fact, trying out practice problems, understanding programming concepts. It was fun and exciting and I love seeing myself growing from nothing in programming to something more. After about 3 months, thing starts to change. I started noticing myself paying less attention to details. I find myself skimming through the course material. I skip "Further Exploration" in the practice problem. I am more interested to study just to pass the assessment rather than truly mastering the concept. It was a gradual burning out process but I continue to study for 10 to 12 hours a day through sheer grit. It felt like doing house chore or working a day job that you don't like. One particular morning I woke up, and I remember this deep feeling of dread because I can anticipate that the next 10 to 1

Sharing my Weakness

It makes sense to know about your weakness and do something about it. Here are my known weaknesses uncovered during my time in Launch School. 1. I don't like to refactor my code   - Your first draft will not be perfect. It works but it may not be efficient/readable/best practices. You final code will almost always be better than your first draft. - It is easier to separate the task between writing code that works and refactor later to make it efficient/readable/best practices. - If you refactor your code often, over time you will discover your bad habits and change it. 2. I don't like to read other people's code - There are more good programming practices in other people than in you (especially for beginners like me). - To be good , you need to know more than one pathways to solve a programming problem (and there are always more than one way). Then you can judge their merit. - Reason for dislikes    1. It is considerably harder to read code than to write one (be