The Hard Parts of Servers & Node.js HTTP Request & Response Q&A
Transcript from the "HTTP Request & Response Q&A" Lesson
>> Will Sentance: Michael, why don't you take it away? You've had some excellent clarification, so take it away.
>> Speaker 2: Does all the data from the computer arrive at once, or does it?
>> Will Sentance: Behind the scenes, there is a way of parsing data over HTTP in what's called chunks. But that is, even if we do want to take that into account and start handling data sooner, or start handling data in chunks, we're gonna have a way of doing that that Node is gonna give us access to.
[00:00:48] But this is so tiny, man, that it's not gonna be in batches. This is just straight in, but yes, in HTTP, you're gonna learn they're called streams of data. I don't love the name because it sounds like it's all happening, the zeroes and ones in a flow, whereas in fact, it's chunk, chunk, and so forth.
[00:01:09] Okay, we'll see more of it soon. Thank you, Michael. Sarah Rose?
>> Speaker 3: So Node is running our, I maybe should have I asked this farther back. Node is running our due on incoming for us, is that happening in our client in the browser? Is that happening on, if that question makes sense.
>> Will Sentance: So everything on this side is Twitter's computer, it's the computer connected to the Internet ready to receive messages from people like Sarah Rose, and so everything here is on Twitter's computer. Excellent.
>> Will Sentance: Bhavit, you had a question.
>> Speaker 2: So we just wrote for a get service call, right?
[00:01:50] So if you have to change, or do we have to declare all get post methods in the beginning, or can we change later?
>> Will Sentance: You can imagine Node being adjusted such that changes from here that were non-breaking to existing things you set up down here. You could make them without having to turn Node off and turn it back on again. But the standard is any changes you make up here are gonna be too breaking to down here.
>> Speaker 2: So if we send in the URL tweets/A say, and this isn't gonna work and it's gonna throw an exception.
[00:03:26] Are we gonna cover what happens when there's an exception? Because I'm curious because what I've seen in my own experience is if you don't handle it, the browser stays connected and it just stays there in that state.
>> Will Sentance: Absolutely, absolutely, and we are,
>> Will Sentance: Going to see how to handle errors.
[00:03:47] In fact, I have a slide coming up that says well, let's see what it says.
>> Will Sentance: Yeah, it's so innate because you're dealing with someone else's computer. We have to have a really sophisticated system for handling errors, yep. Okay, all right, yeah.
>> Speaker 2: Super quick question, it's kind of a dumb question.
>> Will Sentance: I doubt it, I'm sure it's a very insightful question.
>> Speaker 2: So let's say instead of when I display hello, you just wanna display the matter that HTTP request used. So all I have to do is literally just incoming data that mattered, and I'm done.
>> Will Sentance: Done, well, you wanna console log it, right, because you wanna display it to the console.
[00:04:29] You wanna log it to the console, yeah, console log incoming data.method, spot on. Incomingdata.method, you would see get, the string get in.
>> Speaker 2: It's just the property of the object pretty much.
>> Will Sentance: Yep, in fact, this should be a string.
>> Speaker 2: Got you.
>> Will Sentance: It's not a string here, here it's just a text file, it grabs the get bit.
[00:04:47] It's always in the same place in the inbound message and sticks it in as a string on the object that gets inserted. Okay, all right, folk, so now we're about to come to a break in about five, ten minutes during which we're gonna pair program and take lunch.
[00:05:21] Runs that code, switches on Node feature that switches on computer's internal features. How the hell do we do this? Well, let’s see.