Linux command
lwp-request 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
GET request
lwp-request [https://example.com/]
POST request with data
lwp-request -m POST -c 'application/json' -C '[{"key":"value"}]' [https://api.example.com/]
HEAD request
lwp-request -m HEAD [https://example.com/]
Show response headers and content
lwp-request -USed [https://example.com/]
Follow redirects
lwp-request -f [https://example.com/redirect]
Use specific method
lwp-request -m [DELETE] [https://api.example.com/resource]
Set custom header
lwp-request -H 'Authorization: Bearer [token]' [https://api.example.com/]
Save to file
lwp-request [https://example.com/file] > [output]
说明
lwp-request is a command-line HTTP client from the LWP (Library for WWW in Perl) suite. It sends HTTP requests and displays responses. The tool is also available as GET, POST, and HEAD commands, which are symlinks with preset methods. These shortcuts simplify common operations. Output options control what gets printed: request details (-U, -S, -d) and response details (-e, -s). Combined flags show the full transaction for debugging. Authentication, cookies, and proxy settings come from environment variables or configuration files. It integrates with the Perl LWP ecosystem. For simple testing and scripting, lwp-request provides HTTP access without additional dependencies beyond Perl's LWP modules.
参数
- -m _METHOD_
- HTTP method (GET, POST, HEAD, PUT, DELETE).
- -f
- Follow redirects.
- -H _HEADER_
- Add custom header.
- -c _TYPE_
- Content-Type for request body.
- -C _CONTENT_
- Content/body data.
- -b _URI_
- Base URI for relative URLs.
- -o _FORMAT_
- Output format.
- -d
- Print request content/body.
- -e
- Print response headers.
- -s
- Print response status.
- -S
- Print request URL.
- -U
- Print request headers.
- -t _SECONDS_
- Timeout.
- -a
- Use text mode for content.
FAQ
What is the lwp-request command used for?
lwp-request is a command-line HTTP client from the LWP (Library for WWW in Perl) suite. It sends HTTP requests and displays responses. The tool is also available as GET, POST, and HEAD commands, which are symlinks with preset methods. These shortcuts simplify common operations. Output options control what gets printed: request details (-U, -S, -d) and response details (-e, -s). Combined flags show the full transaction for debugging. Authentication, cookies, and proxy settings come from environment variables or configuration files. It integrates with the Perl LWP ecosystem. For simple testing and scripting, lwp-request provides HTTP access without additional dependencies beyond Perl's LWP modules.
How do I run a basic lwp-request example?
Run `lwp-request [https://example.com/]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -m _METHOD_ do in lwp-request?
HTTP method (GET, POST, HEAD, PUT, DELETE).