current position:Home>Zhang San has a meal - did he eat the difference between get and post in HTTP?

Zhang San has a meal - did he eat the difference between get and post in HTTP?

2022-05-15 02:42:01Hua Weiyun

Reading tips : The core content is The scarlet letter , If you want to extract key information, please read the scarlet letter , If you want to see the whole story , Please read in order .

background : It's an ordinary night , It was also an extraordinary night . Late at night , Steamed Rice King ——''POST. Zhang San '' and noodles The emperor ——''GET. Li Si ''( Hereinafter referred to as" : Zhang San po、 Li Si ge), The two brothers were beaten by the big brother of object-oriented programming , Forced to drift to Mount Everest in the computer network —— The five-star Inn on the application layer mountain ——HTTP Inn —— having dinner !!!

         Just entered the hotel , A column of prominent slogans at the door of the hotel came into view : 


  • http1.0 and http1.1 It's all based on TCP/IP Application layer protocol ,GET Methods and POST Methods are sent at the transport layer tcp Message transmission , There is no difference in essence , But in practice , There will be a difference .

         Now Zhang San po The student asked : Since there is no difference in essence , Why do you have to divide GET and POST Method ?

         Li Si ge: You are so stupid ! Then you usually eat , Why eat with chopsticks and spoon ......

        Zhang San po: No , My chopsticks ran away with people last year , In recent years, I only eat with a spoon .

        Li Si ge: roll !!!

  • transmission tcp message = Zhang San po And Li Si ge The process of eating                       
  • Use POST Method and use GET Method = Eat with a spoon and chopsticks
  • Set up POST、GET Purpose : To complete tcp Multiple processing methods are set for transmission message

        Li Si ge I'll see you for a long time , So he asked : Don't you know there is something called noodles in the world ? Don't tell me. , You never eat noodles with chopsticks ?

        Zhang San po: No , I never eat noodles , I only eat rice , So everyone calls me king of rice —— Zhang San po.

  • Spoon = POST           chopsticks = GET
  • Use POST Submit data  = Use a spoon to eat rice
  • Use GET Get web information =  Use chopsticks to eat noodles
  • To deal with different things , Define different methods , Targeted treatment

        Zhang San po See Li Si ge Not too smart , So I went straight to the shopkeeper and ordered a bowl Fish bone noodles , Found a place far away from Li Si ge Sit down in the corner and rest , Li Si ge before , Learn Zhang San in a modular way po The appearance of , Ordered a , The super essence version is big Dace rice ball —— Then he sat on Li Si ge side .

        The inn is very efficient , Delicious rice balls and hot noodles 10 It'll be on the table in seconds , The two tacitly wolfed down .

        Li Si ge Wordy at one breath 3 strip 2 Rice long noodles , But my mouth is not big enough , It can only be clamped off , Divided into two wordy .

        Zhang San po: Li Si ge, Do you know how many grains of rice I eat with a spoon ?

        Li Si ge: Your rice balls are lump by lump , Directly into a big Body, How do I know how many pills there are ???

        Zhang San po: But I can see that you are wordy with chopsticks 3 Noodles !!!

        Li Si ge: Why should I let you see me eat some noodles , So that you can ask me this question !!!!!

  • The number of grains of rice eaten by a spoon ——POST Data parameters are not visible , The information is filled in Body Partial transmission
  • The number of noodles eaten with chopsticks ——GET The data parameters are visible in the address bar , The data parameters are spliced in URL after ( Insecurity )
  • There is no rule on how long a mouthful of noodles can only be wordy , But the size of the mouth is limited , Limit the length of wordy noodles ——
  • HTTP The standard is not clearly formulated URL The length of , But general browsers support URL The length is , Therefore use GET The transmission of data will receive URL Length limitation .

        Li Si ge: I will never forget this night

        Zhang San po: Why ? Is it because you are so happy with me that you will never forget it ? I'm so sorry !

  • POST The request will not be cached by the browser ( Push agreement )
  • GET The request will be cached by the browser ( Pull agreement ), Never forget ~

       (hint:  The ancestral traditional ceremony of their school , After a meal, you must shout : I'm full ! To show respect for the hard work of the working people )  (hint: Eat noodles , It means there is really no fish bone , Eat the rice balls , May be stuck in the throat , Have to confirm twice )   

         Ten minutes passed , Li Si ge: I'm full !( Means no fish bones )

        Zhang San po Throw the big bowl on the table , Shout : I'm full !

        Zhang San po: no ...... no ...... Cough ......ge, Li Si ge I got stuck on a fishbone !!!

  • GET Request header and data Send along , With one ~
  • POST The request first sends the request header , Wait for the server to respond , Sending data
  • When the network environment is good , The time difference between two packets can be ignored , stay Firefox in POST Send the bag only once .

( The food in this shop is unique in the world , People who haven't practiced stomach strength can't digest , Zhang San po I haven't practiced , But Li Si ge Practise ) 

        Soon in Li Si ge With the help of the , Zhang San po Successfully remove the fishbone , But at this moment , Zhang San po My stomach can't digest the dace rice balls in this inn , So my stomach hurts , And Li Si ge But nothing .

  • The stomach = The server        
  • The server needs to get the requested data in a specific way  
  • The server processes GET Need to pass through Request.QueryString To get data
  • The server processes POST Need to pass through Request.Form To get data

         After a struggle , Zhang San po Successfully spit out the fish bone just eaten , By the way, at Li Si ge I also vomited a few lumps of rice balls just after my stomach . Li Si ge Felt a trace of pain , He struggled , Hesitating , Shouting , But he still didn't spit out , His stomach gradually became powerful —— How powerful —— Get stronger —— In less than a quarter of an hour , Li Si ge Gained a superpower —— Permanent immunity Zhang San po Vomit attack !!! And zhang SAN po After suffering like hell , Since then, the stomach has been invincible !!!

  • Zhang San po Changed the function of the stomach and became more powerful
  • Li Si ge Left a permanent immunity
  • POST You can modify the resources on the variable server
  • GET The requested resource will Actively cached by the browser , Request the same content again , The contents of the cache will be returned

        At this time , The innkeeper saw that the two martial brothers were so determined , Morality is so noble , He took out the treasure of the town store —— Pandora's box , Give the two martial brothers a chance to go back to the past ! Back into the store , Have a good night .

        Li Si ge In a hurry : You want me to experience it again ??? I might as well be beaten up by object-oriented programming .

        Zhang San po: If God gives me another chance to go back to the past , I would say : I am willing to !!!

  • POST Request to step back —— Resubmit the request
  • GET Request fallback —— No influence ( cache )

Summary  

http1.0 and http1.1 It's all based on TCP/IP Application layer protocol ,GET Methods and POST Methods are sent at the transport layer tcp Message transmission , There is no difference in essence , But in practice , There will be a difference .
  • Set up POST、GET Purpose : To complete tcp Multiple processing methods are set for transmission message , To deal with different things , Define different methods , Targeted treatment
  • POST Data parameters are not visible , The information is filled in Body Partial transmission
  • GET The data parameters are visible in the address bar , The data parameters are spliced in URL after ( Insecurity )
  • HTTP The standard is not clearly formulated URL The length of , But general browsers support URL The length is , Therefore use GET The transmission of data will receive URL Length limitation .
  • POST The request will not be cached by the browser ( Push agreement )
  • GET The request will be cached by the browser ( Pull agreement )
  • GET Request header and data Send along
  • POST The request first sends the request header , Wait for the server to respond , Sending data
  • The server needs to get the requested data in a specific way  
  • The server processes GET Need to pass through Request.QueryString To get data
  • The server processes POST Need to pass through Request.Form To get data
  • POST You can modify the resources on the variable server
  • GET The requested resource will Actively cached by the browser , Request the same content again , The contents of the cache will be returned
  • POST Request to step back —— Resubmit the request
  • GET Request fallback —— No influence ( cache )

Bloggers try for the first time Story style Explain and introduce knowledge , If there are shortcomings , Welcome comments, private letters, criticism and correction .

copyright notice
author[Hua Weiyun],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/135/202205142117395082.html

Random recommended