HTTP

Form Data vs Json of Backend Api

通过浏览器提交表单 通过curl提交表单 spring-boot map HTTP request header Content-Type, handle request body. @RequestParam ← application/x-www-form-urlencoded, @RequestBody ← application/json, @RequestPart ← multipart/form-data, form-data

Vue Deployed in Non-Root Nginx Location

deploy VUE app under myweb context path server { listen 80; server_name 127.0.0.1; #listen 443 ssl; location /ibms/api/ { proxy_pass http://127.0.0.1:8080/; #proxy_set_header Host $http_host; add_header Cache-Control no-cache; add_header Pragma no-cache; add_header Expires 0; proxy_connect_timeout 200s; proxy_send_timeout 200s; proxy_read_timeout 200s; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header sn $http_sn; #405 重新代理 error_page 405 =200 http://$host$request_uri; } location /ibms { root /var/www/html; add_header Cache-Control no-cache; add_header Pragma no-cache; add_header Expires 0; #try_files $uri $uri/ @router; try_files $uri $uri/ /ibms/index.

HTTP/3

track http redirection http://wubigo.com/post -> http://wubigo.com/post/ -> https://wubigo.com/post/ curl -IL http://wubigo.com/post HTTP/1.1 301 Moved Permanently Location: https://wubigo.com/post Via: 1.1 varnish X-Cache: HIT X-Cache-Hits: 1 HTTP/1.1 200 OK Content-Length: 0 HTTP/1.1 301 Moved Permanently Strict-Transport-Security: max-age=31556952 Location: http://wubigo.com/post/ Access-Control-Allow-Origin: * X-Cache: HIT X-Cache-Hits: 1 HTTP/1.1 301 Moved Permanently Location: https://wubigo.com/post/ X-Cache: HIT X-Cache-Hits: 1 HTTP/1.1 200 OK Access-Control-Allow-Origin: * Cache-Control: max-age=600 X-Cache: HIT X-Cache-Hits: 1 main goal HTTP/2’s multiplexed connections, allowing multiple streams of data to reach all the endpoints independently.

REST API中如何使用Http状态码

Status-Line The first line of a Response message is the Status-Line, consisting of the protocol version followed by a numeric status code and its associated textual phrase, with each element separated by SP characters. No CR or LF is allowed except in the final CRLF sequence. Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF status code vs status in body https://www.codetinkerer.com/2015/12/04/choosing-an-http-status-code.html https://httpstatuses.com/ The main choice is do you want to treat the HTTP status code as part of your REST API or not.

HTTP Session Management

COOKIE & HTTP SESSION H5 addition that adds a key/value store to browsers and cookies stateful session Some examples of scaling stateful sessions: Once you run multiple backend processes on a server: A Redis daemon (on that server) for session storage. Once you run on multiple servers: A dedicated server running Redis just for session storage. Once you run on multiple servers, in multiple clusters: Sticky sessions. JWT session Stateless JWT: A JWT token that contains the session data, encoded directly into the token.