lwp-request command example – The Ranjan.info


lwp-requests is a straightforward command-line HTTP client tool designed to make HTTP requests from a command line interface. It is built using the libwww-perl library, which provides a comprehensive set of Perl modules for interacting with the World Wide Web.

Key features and functionalities of LWP-Request include:

  • HTTP Client:lwp-requests serves as a simple but powerful HTTP client, allowing users to send various types of HTTP requests, such as GET, POST, PUT, DELETE, HEAD and OPTIONS, to a web server. It enables users to interact with web services, APIs, and websites directly from the command line, without the need for a dedicated web browser or complex scripting.
  • command line interface: As a command-line tool, lwp-request is easy to use and can be invoked directly from the terminal or command prompt. Users can specify the desired HTTP method, URL, headers, request body, and other parameters as command-line arguments, making it convenient for one-time requests, scripting, automation, and testing tasks.
  • flexible request configuration:lwp-request provides flexibility in configuring HTTP requests by allowing users to customize various aspects of the request, including request headers, content type, authentication credentials, user agent, and more. This flexibility enables users to tailor their requests to specific needs and scenarios.
  • Support for HTTPS: lwp-request supports HTTPS (HTTP over SSL/TLS) connections, which ensures secure communication between the client and the server. It allows users to make requests to HTTPS-enabled websites and APIs while benefiting from the encryption and data integrity provided by the SSL/TLS protocol.
  • feedback management:After sending an HTTP request, lwp-request displays the response received from the server, including the HTTP status code, response headers, and response body. It allows users to inspect the server's response and extract relevant information for further processing or analysis.
  • Integration with Perl: Being built with libwww-perl, lwp-request integrates natively with Perl scripts and applications, enabling developers to include HTTP client functionality in their Perl projects. This integration allows developers to leverage a rich set of Perl libraries and modules for web scraping, data retrieval, API consumption, and more.
  • Cross-platform compatibility:lwp-request is cross-platform and runs on various operating systems including Linux, macOS, and Windows, making it accessible to a wide range of users and environments. This ensures consistent behavior and performance across different platforms, allowing users to use lwp-requests wherever Perl and libwww-perl are available.

lwp-request command example

1. Make a simple GET request:

# get lwp-request -m [

2. Upload a file with a POST request:

# lwp-request -m POST [ 

3. Make a request with a custom user agent:

# lwp-request -H 'User-Agent: [user_agent] -M [METHOD] [

4. Make a request with HTTP authentication:

# lwp-request -C [username],[password] -M [METHOD] [

5. Make a request and print request headers:

# lwp-request -U -m [METHOD] [

6. Make a request and print response headers and status chain:

# lwp-request -E -m [METHOD]    ,[[


In short, lwp-requests is a versatile and user-friendly command-line HTTP client tool that provides a convenient way to make HTTP requests, interact with web services, and retrieve data from web servers directly from a command line interface. With its simplicity, flexibility, HTTPS support, response management capabilities, Perl integration, and cross-platform compatibility, lwp-request is a valuable tool for developers, system admins, and users.

Add comment

By Ranjan