- Go Web Scraping Quick Start Guide
- Vincent Smith
- 251字
- 2021-07-02 13:58:17
Request body
Query parameters are typically only used on HTTP GET requests. For requests where you are sending data to the server, such as POST and PUT requests, you would send a request body that holds all of your extra information. Request bodies are placed after the HTTP headers in an HTTP request, with a one-line space between them. The following is a hypothetical POST request for logging into an imaginary website:
POST /login HTTP/1.1
Host: myprotectedsite.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 38
username=myuser&password=supersecretpw
In this request, we are sending our username and password to myprotectedsite.com/login. The headers for this request must describe the request body so the server is able to process it. In this case, we declare that the request body be in the x-www-form-urlencoded format, which is the same format used for the query parameters in the Query parameters section. We could use alternative formats, such as JSON or XML or even plain text, but only if it is supported by the server. The x-www-form-urlencoded format is the most widely supported and is generally a safe bet. The second parameter we define in the header is the length of the request body in bytes. This allows the server to efficiently prepare for processing the data, or rejecting the request completely if it is too large.
The Go standard library has good support for building HTTP requests quite simply—if you are familiar with the structure, at least. We will revisit how this is done later in this chapter.
- 網絡云百問百答
- 黑客攻防實戰技術完全手冊:掃描、嗅探、入侵與防御
- 網絡協議工程
- 電子政務效益的經濟分析與評價
- 通信簡史:從信鴿到6G+
- Building RESTful Web Services with Spring 5(Second Edition)
- React:Cross-Platform Application Development with React Native
- SSL VPN : Understanding, evaluating and planning secure, web/based remote access
- 中小型局域網組建、管理與維護實戰
- 網絡安全應急響應技術實戰
- Mastering Dart
- 網絡基礎與網絡管理項目化教程
- 網絡環境中基于用戶視角的信息質量評價研究
- 6G:面向2030年的移動通信
- 人人都該都懂的互聯網思維