Adventures in HTTP (Part 1)

Chapter 1: Nginx Building
The car finally arrived, and I got out with the safe. I thought this should be the destination, a building called mytaobao.com, with two entrances: “Channel 80” and “Channel 443”.
When I set off from Browser Village, Old IE told me to find this building, enter through the secure channel, and naturally, someone would receive me.
(Note from the coder: For Old IE, see “Why IE Injured Chrome and Firefox”)
Which is the secure channel? I saw many people coming in and out of both channels, and I was a bit puzzled. Just then, a security guard came out and said to me in a disdainful tone:
“What are you still doing? Hurry up and enter Channel 443!”
“Why?”
“Didn’t you see the vehicle that brought you here? It said HTTPS: Port 443”
Oh, I really didn’t notice, so I hurried in.
Entering Channel 443, just as Old IE said, someone immediately came over, wearing a service uniform, and said enthusiastically:
“I am Worker 4, happy to serve you”
“Worker? Is this still a feudal society?”
“Yes, we still have landlords here, who occasionally issue orders to us four workers and exploit us heavily. Look at all these people in front, so much work, and only we four workers are doing it.”
I looked ahead, and sure enough, the lobby was bustling, but I only saw four people in service uniforms.
“I established a connection with your Old IE a long time ago, why are you just arriving now?” Worker 4 asked me.
“Sigh, the journey was really too long. First, I took a donkey cart from Browser Village, then a car, then a plane, and I had to transfer through several routers several times before finally arriving here.”
Worker 4 had an office desk surrounded by many people, all asking him:
“Has my image been retrieved yet? I’ve been waiting for half a day!”
“Where’s my javascript file?”
“What about my css?”
“Where’s my html?”
If it were me, I would have exploded, but Worker 4 seemed unfazed, calmly replying, “Sorry, please wait a bit. I will notify you when the data is retrieved.”
Upon hearing this, my mind lit up. I had read “Node.js: I Just Need a Shop Assistant”, and it seemed these workers worked similarly to Node.js, handling all clients in an event-driven manner. No wonder they could serve so many people with just four workers.
Worker 4 said to me: “Give me your safe. When I established the connection with your Old IE, I already confirmed the key. I can only see the packages inside after I open it.”
(Note from the coder: The safe and key refer to encrypted communication, i.e., HTTPS. See “The Second Interview with Browser Village”)
I placed the safe on the ground, and he took out the key and opened it smoothly. The package inside was labeled: HTTP POST login.action
“Oh, this package request cannot be processed here; you need to go to the Tomcat building.”
“Why?”
“We Nginx only handle static files like images, javascript, and html files. The request here is for a dynamic page, login.action, which needs to be executed by the backend Tomcat application to resolve.”
“Where is Tomcat?” I asked.
“We have four Tomcats here; wait a moment, let me see which Tomcat building has fewer people. Hmm, you should go to Tomcat at 192.168.0.102, take Channel 8080.”
I was wondering if I still needed to take a donkey cart; that would be too painful.
Worker 4 probably saw my thoughts and pointed me to a pipe, saying: “Just jump in; you’ll get there quickly.”
The people around looked at me with glee, as if I were going on a one-way trip.
I gritted my teeth and jumped in.
Chapter 2: Tomcat
This was just a slide connecting the two buildings. I comfortably slid from the Nginx building into a lobby in the Tomcat building.
Upon landing, I saw that there were indeed many people here, but there was a significant difference from the Nginx building:
There, four workers were being “attacked” by everyone, clamoring and shouting; here, everyone had a service staff member in a yellow uniform providing one-on-one attentive service, making it much quieter.
Suddenly, a loudspeaker announced: “0x6904, guests have arrived, hurry to greet them.”
A short guy ran out from a nearby room, also in a yellow uniform, with a name tag that read: Thread 0x6904.
“May I help you, sir?” This guy was still a fake foreigner, and I got angry as soon as I heard him.
“Process this package for me,” I said curtly.
0x6904 didn’t speak, just extended his hand, quickly rubbing his thumb against his index and middle fingers, clearly asking for money.
I got even angrier: “Do you charge here? Nginx has one worker serving so many people without charging anything.”
“Nginx, I know, their salaries are high. Don’t look at us having 200 people here; we also pay our salaries per person served, but our boss stipulates that this is one-on-one VIP attentive service. Now it’s the off-season; I might not even serve a few guests in a day. How can I survive without collecting some tips?”
I thought about it and agreed, giving him 10 bucks.
0x6904 took the package this time, then pulled out a piece of paper from his pocket, slowly reading for a while and said:
“You want to process login.action, huh? Look, our web.xml states clearly that your package is processed by the Struts filter boss.”
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
All .action requests must find the Struts Filter boss, and my package is no exception.
The Filter boss’s room was very grand, especially the wall, which was densely covered with various forms and arrows. 0x6904 went forward to inquire, and I stood there looking at the struts.xml on the wall.
I found it stated login –> LoginAction.java. Could it be that I also need to find LoginAction.java?
“Boss, please help take a look at this package,” 0x6904 asked.
The Filter boss was extremely busy, just glanced at it without raising his head: “Go to the second floor to find LoginAction.”
Indeed! I guessed he had processed countless such packages before, as the forms and icons on the wall had all yellowed; he must have memorized (cached) these things, so he didn’t even need to check.
(To be continued)
Related Reading:
“Why IE Injured Chrome and Firefox”
“The Second Interview with Browser Village”
“Node.js: I Just Need a Shop Assistant”
Adventures in HTTP (Part 1)
Public Account: Coder’s Rebirth
“Coder’s Rebirth” public account was created by a former IBM architect with 15 years of experience, sharing lessons and experiences in programming and the workplace.

Leave a Comment