3 - Web Computing, Server Organization Flashcards

(21 cards)

1
Q

How does HTTP connection work for client and server?

A
  1. Client opens connection, sends request to HTTP server
  2. Server sends response
  3. Server closes connection
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 3 parts of the HTTP request?

A
  1. message type (start line)
  2. header lines, followed by blank line
  3. body
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 3 parts of the message type?

A
  1. Request type (GET, POST, PUT, etc.)
  2. Absolute path
  3. HTTP version
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are some useful headers?

A

content-length - required if sending a body
Content-Type - what’s in body
User-Agent - browser type
Referer[sic] - where it came from

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the status codes meanings? (Each 100 level)

A

100s - info
200s - success
300s - redirects
400s - client errors
500s - server error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a GET?

A

Basic web server sends files in response to a request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a POST?

A

Send data to server (login, forum post reply)

  • Should make a NEW item
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to parse a GET?

A

Get the text

  • fetch the file, make some headers, and reply
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to parse a POST?

A

something with JSONs - check notes

  • encode content into key/value pairs
  • put encoded data into body
  • POST it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you create “state”? in HTTP?

A

Cookies!
- server sets cookies in browser
- browser sends those cookies with every response

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are some ways so that we don’t change pages all the time?

A

SPA - single page application

AJAX - async. Javascript and XML

  • send a request “behind the scenes” update the HTML of the page (Domain Object Model)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do we avoid keeping username/password in our cookie and remove them?

A
  • we can set the “Set-Cookie” of the password to an expiry date in the past
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

For path /user/11, what would GET, POST, PUT, and DELETE do?

A

GET - fetch user info
POST - (doesnt make sense, we post a user to create one)
PUT - update user
DELETE - remove/disable user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a safe method?

A

GET, HEAD, OPTIONS, TRACE

  • allows for optimization, usually read only and doesn’t change anything so we can cache this info
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does idempotent mean?

A

No matter how many times it’s done, the result is the same

  • all safe methods are idempotent, but not vice versa
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Think about adding a discussion post. Write the methods + data send to create these posts:
1) Go to UMLearn
2) Log into UMLearn
3) Move to 3010 via waffle menu
4) Add a discussion thread
5) update spelling mistake in thread

A

1) GET
2) POST
3) GET
4) POST
5) POST
6) POST -> why post for 6? Gives info of what you’re changing, no guarantee if its a new post or an update

17
Q

Why aren’t Form POSTs not used as much anymore?

A
  • we don’t want to see the browser completely refresh (complete changes take many resources
  • replaced with XHR
18
Q

Why shouldn’t we just set the full username and password as a cookie?

A

If your session is open, someone can just check the cookies

  • serverside could see this but they shouldn’t
19
Q

Why is API preferred?

A
  • decouples frontend from backend
  • can have multiple front-ends (app, web, watch, etc.)
  • simple, lightweight, subdivide load
  • better organization
20
Q

What are the pros and cons of server pages (SSR)

A

pros:
- better SEO (scraper gets everything)
- doesn’t need JS to load everything

cons:
- lots of server load
- lots of time for client to receive data

21
Q

Why is PHP good, and why is it bad?

A

Good:
- returns dynamic content precomputed by server

Bad:
- too many layers in one (scripts + front-end combined)
- adding plugins into wordpress is insecure (code you didn’t write is on your server, better trust it)