{"id":28089474,"url":"https://github.com/raku-community-modules/http-useragent","last_synced_at":"2025-12-16T19:03:43.378Z","repository":{"id":6987454,"uuid":"8250196","full_name":"raku-community-modules/HTTP-UserAgent","owner":"raku-community-modules","description":"Web user agent class for Raku","archived":false,"fork":false,"pushed_at":"2025-05-03T22:28:23.000Z","size":451,"stargazers_count":38,"open_issues_count":40,"forks_count":39,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-10T04:49:56.234Z","etag":null,"topics":["cookie","cookiejar","rakulang","ssl","user-agent"],"latest_commit_sha":null,"homepage":"https://raku.land/zef:raku-community-modules/HTTP::UserAgent","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raku-community-modules.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"sergot"}},"created_at":"2013-02-17T12:18:17.000Z","updated_at":"2025-05-04T11:53:24.000Z","dependencies_parsed_at":"2024-01-29T13:41:51.092Z","dependency_job_id":"b59f8c5e-3dcf-4159-8ea7-f38c76a2d747","html_url":"https://github.com/raku-community-modules/HTTP-UserAgent","commit_stats":{"total_commits":506,"total_committers":47,"mean_commits":10.76595744680851,"dds":0.6877470355731226,"last_synced_commit":"531f6fb8d8ef56c190086e2d2da93a9ce2b7627d"},"previous_names":["raku-community-modules/http-useragent"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-UserAgent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-UserAgent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-UserAgent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FHTTP-UserAgent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raku-community-modules","download_url":"https://codeload.github.com/raku-community-modules/HTTP-UserAgent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948387,"owners_count":21988953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cookie","cookiejar","rakulang","ssl","user-agent"],"created_at":"2025-05-13T12:58:40.407Z","updated_at":"2025-12-16T19:03:38.335Z","avatar_url":"https://github.com/raku-community-modules.png","language":"Raku","funding_links":["https://github.com/sponsors/sergot"],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/raku-community-modules/HTTP-UserAgent/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/HTTP-UserAgent/actions) [![Actions Status](https://github.com/raku-community-modules/HTTP-UserAgent/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/HTTP-UserAgent/actions)\n\nNAME\n====\n\nHTTP::UserAgent - Web user agent class\n\nSYNOPSIS\n========\n\n```raku\nuse HTTP::UserAgent;\n\nmy $ua = HTTP::UserAgent.new;\n$ua.timeout = 10;\n\nmy $response = $ua.get(\"URL\");\n\nif $response.is-success {\n    say $response.content;\n}\nelse {\n    die $response.status-line;\n}\n```\n\nDESCRIPTION\n===========\n\nThis module provides functionality to crawling the web witha handling cookies and correct User-Agent value.\n\nIt has TLS/SSL support.\n\nMETHODS\n=======\n\nmethod new\n----------\n\n```raku\nmethod new(HTTP::UserAgent:U: :$!useragent, Bool :$!throw-exceptions, :$!max-redirects = 5, :$!debug)\n```\n\nDefault constructor.\n\nThere are four optional named arguments:\n\n  * useragent\n\nA string that specifies what will be provided in the `User-Agent` header in the request. A number of standard user agents are described in [HTTP::UserAgent::Common](HTTP::UserAgent::Common), but a string that is not specified there will be used verbatim.\n\n  * throw-exceptions\n\nBy default the `request` method will not throw an exception if the response from the server indicates that the request was unsuccesful, in this case you should check `is-success` to determine the status of the [HTTP::Response](HTTP::Response) returned. If this is specified then an exception will be thrown if the request was not a success, however you can still retrieve the response from the `response` attribute of the exception object.\n\n  * max-redirects\n\nThis is the maximum number of redirects allowed for a single request, if this is exceeded then an exception will be thrown (this is not covered by `no-exceptions` above and will always be throw,) the default value is 5.\n\n  * debug\n\nIt can etheir be a Bool like simply `:debug` or you can pass it a IO::Handle or a file name. Eg `:debug($*ERR)` will ouput on stderr `:debug(\"mylog.txt\")` will ouput on the file.\n\nmethod auth\n-----------\n\n```raku\nmethod auth(HTTP::UserAgent:, Str $login, Str $password)\n```\n\nSets username and password needed to HTTP Auth.\n\nmethod get\n----------\n\n```raku\nmulti method get(Str $url is copy, :bin?, *%headers)\nmulti method get(URI $uri, :bin?, *%headers)\n```\n\nRequests the $url site, returns HTTP::Response, except if throw-exceptions is set as described above whereby an exception will be thrown if the response indicates that the request wasn't successfull.\n\nIf the Content-Type of the response indicates that the content is text the `content` of the Response will be a decoded string, otherwise it will be left as a [Blob](Blob).\n\nIf the ':bin' adverb is supplied this will force the response `content` to always be an undecoded [Blob](Blob)\n\nAny additional named arguments will be applied as headers in the request.\n\nmethod post\n-----------\n\n```raku\nmulti method post(URI $uri, %form, *%header ) -\u003e HTTP::Response\nmulti method post(Str $uri, %form, *%header ) -\u003e HTTP::Response\n```\n\nMake a POST request to the specified uri, with the provided Hash of %form data in the body encoded as \"application/x-www-form-urlencoded\" content. Any additional named style arguments will be applied as headers in the request.\n\nAn [HTTP::Response](HTTP::Response) will be returned, except if throw-exceptions has been set and the response indicates the request was not successfull.\n\nIf the Content-Type of the response indicates that the content is text the `content` of the Response will be a decoded string, otherwise it will be left as a [Blob](Blob).\n\nIf the ':bin' adverb is supplied this will force the response `content` to always be an undecoded [Blob](Blob)\n\nIf greater control over the content of the request is required you should create an [HTTP::Request](HTTP::Request) directly and populate it as needed,\n\nmethod request\n--------------\n\n```raku\nmethod request(HTTP::Request $request, :bin?)\n```\n\nPerforms the request described by the supplied [HTTP::Request](HTTP::Request), returns a [HTTP::Response](HTTP::Response), except if throw-exceptions is set as described above whereby an exception will be thrown if the response indicates that the request wasn't successful.\n\nIf the response has a 'Content-Encoding' header that indicates that the content was compressed, then it will attempt to inflate the data using [Compress::Zlib](Compress::Zlib), if the module is not installed then an exception will be thrown. If you do not have or do not want to install [Compress::Zlib](Compress::Zlib) then you should be able to send an 'Accept-Encoding' header with a value of 'identity' which should cause a well behaved server to send the content verbatim if it is able to.\n\nIf the Content-Type of the response indicates that the content is text the `content` of the Response will be a decoded string, otherwise it will be left as a [Blob](Blob). The content-types that are always considered to be binary (and thus left as a [Blob](Blob) ) are those with the major-types of 'image','audio' and 'video', certain 'application' types are considered to be 'text' (e.g. 'xml', 'javascript', 'json').\n\nIf the ':bin' adverb is supplied this will force the response `content` to always be an undecoded [Blob](Blob)\n\nYou can use the helper subroutines defined in [HTTP::Request::Common](HTTP::Request::Common) to create the [HTTP::Request](HTTP::Request) for you or create it yourself if you have more complex requirements.\n\nroutine get :simple\n-------------------\n\n```raku\nsub get(Str $url) returns Str is export(:simple)\n```\n\nLike method get, but returns decoded content of the response.\n\nroutine head :simple\n--------------------\n\n```raku\nsub head(Str $url) returns Parcel is export(:simple)\n```\n\nReturns values of following header fields:\n\n  * Content-Type\n\n  * Content-Length\n\n  * Last-Modified\n\n  * Expires\n\n  * Server\n\nroutine getstore :simple\n------------------------\n\n```raku\nsub getstore(Str $url, Str $file) is export(:simple)\n```\n\nLike routine get but writes the content to a file.\n\nroutine getprint :simple\n------------------------\n\n```raku\nsub getprint(Str $url) is export(:simple)\n```\n\nLike routine get but prints the content and returns the response code.\n\nSUPPORT MODULES\n===============\n\nHTTP::Cookie - HTTP cookie class\n--------------------------------\n\nThis module encapsulates single HTTP Cookie.\n\n```raku\nuse HTTP::Cookie;\n\nmy $cookie = HTTP::Cookie.new(:name\u003ctest_name\u003e, :value\u003ctest_value\u003e);\nsay ~$cookie;\n```\n\nThe following methods are provided:\n\n### method new\n\n```raku\nmy $c = HTTP::Cookie.new(:name\u003ca_cookie\u003e, :value\u003ca_value\u003e, :secure, fields =\u003e (a =\u003e b));\n```\n\nA constructor, it takes these named arguments:\n\n\u003ctable class=\"pod-table\"\u003e\n\u003cthead\u003e\u003ctr\u003e\n\u003cth\u003ekey\u003c/th\u003e \u003cth\u003edescription\u003c/th\u003e\n\u003c/tr\u003e\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e \u003ctd\u003ename\u003c/td\u003e \u003ctd\u003ename of a cookie\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003evalue\u003c/td\u003e \u003ctd\u003evalue of a cookie\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003esecure\u003c/td\u003e \u003ctd\u003eSecure param\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003ehttponly\u003c/td\u003e \u003ctd\u003eHttpOnly param\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003efields\u003c/td\u003e \u003ctd\u003elist of field Pairs (field =\u0026gt; value)\u003c/td\u003e \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n### method Str\n\nReturns a cookie as a string in readable (RFC2109) form.\n\nHTTP::Cookies - HTTP cookie jars\n--------------------------------\n\nThis module provides a bunch of methods to manage HTTP cookies.\n\n```raku\nuse HTTP::Cookies;\nmy $cookies = HTTP::Cookies.new(\n  :file\u003c./cookies\u003e,\n  :autosave\n);\n$cookies.load;\n```\n\n### method new\n\n```raku\nmy $cookies = HTTP::Cookies.new(\n  :file\u003c./cookies.here\u003e\n  :autosave,\n);\n\nConstructor, takes named arguments:\n```\n\n\u003ctable class=\"pod-table\"\u003e\n\u003cthead\u003e\u003ctr\u003e\n\u003cth\u003ekey\u003c/th\u003e \u003cth\u003edescription\u003c/th\u003e\n\u003c/tr\u003e\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e \u003ctd\u003efile\u003c/td\u003e \u003ctd\u003ewhere to write cookies\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003eautosave\u003c/td\u003e \u003ctd\u003esave automatically after every operation on cookies or not\u003c/td\u003e \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n### method set-cookie\n\n```raku\nmy $cookies = HTTP::Cookies.new;\n$cookies.set-cookie('Set-Cookie: name1=value1; HttpOnly');\n```\n\nAdds a cookie (passed as an argument $str of type Str) to the list of cookies.\n\n### method save\n\n```raku\nmy $cookies = HTTP::Cookies.new;\n$cookies.set-cookie('Set-Cookie: name1=value1; HttpOnly');\n$cookies.save;\n```\n\nSaves cookies to the file ($.file).\n\n### method load\n\n```raku\nmy $cookies = HTTP::Cookies.new;\n$cookies.load;\n```\n\nLoads cookies from file specified at instantiation ($.file).\n\n### method extract-cookies\n\n```raku\nmy $cookies = HTTP::Cookies.new;\nmy $response = HTTP::Response.new(Set-Cookie =\u003e \"name1=value; Secure\");\n$cookies.extract-cookies($response);\n```\n\nGets cookies ('Set-Cookie: ' lines) from the HTTP Response and adds it to the list of cookies.\n\n### method add-cookie-header\n\n```raku\nmy $cookies = HTTP::Cookies.new;\nmy $request = HTTP::Request.new;\n$cookies.load;\n$cookies.add-cookie-header($request);\n```\n\nAdds cookies fields ('Cookie: ' lines) to the HTTP Request.\n\n### method clear-expired\n\n```raku\nmy $cookies = HTTP::Cookies.new;\n$cookies.set-cookie('Set-Cookie: name1=value1; Secure');\n$cookies.set-cookie('Set-Cookie: name2=value2; Expires=Wed, 09 Jun 2021 10:18:14 GMT');\n$cookies.clear-expired; # contains 'name1' cookie only\n```\n\nRemoves expired cookies.\n\n### method clear\n\n```raku\nmy $cookies = HTTP::Cookies.new;\n$cookies.load;   # contains something\n$cookies.clear;  # will be empty after this action\n```\n\nRemoves all cookies.\n\n### method push-cookie\n\n```raku\nmy $c = HTTP::Cookie.new(:name\u003ca\u003e, :value\u003cb\u003e, :httponly);\nmy $cookies = HTTP::Cookies.new;\n$cookies.push-cookie: $c;\n```\n\nPushes cookies (passed as an argument $c of type HTTP::Cookie) to the list of cookies.\n\n### method Str\n\nReturns all cookies in human (and server) readable form.\n\nHTTP::UserAgent::Common - the most commonly used User-Agents\n------------------------------------------------------------\n\nThis module provides a list of the most commonly used User-Agents.\n\n```raku\nuse HTTP::UserAgent::Common;\nsay get-ua('chrome_linux');\n```\n\n### routine get-ua\n\n```raku\nsay get-ua('chrome_linux');\n```\n\nReturns correct UserAgent or unchaged passed argument if UserAgent could not be found.\n\nAvailable UserAgents:\n\n    chrome_w7_64 firefox_w7_64 ie_w7_64 chrome_w81_64 firefox_w81_64 mob_safari_osx\n    safari_osx chrome_osx firefox_linux chrome_linux\n\nHTTP::Header - class encapsulating HTTP message header\n------------------------------------------------------\n\nThis module provides a class with a set of methods making us able to easily handle HTTP message headers.\n\n```raku\nuse HTTP::Header;\nmy $h = HTTP::Header.new;\n$h.field(Accept =\u003e 'text/plain');\nsay $h.field('Accept');\n$h.remove-field('Accept');\n```\n\n### method new\n\n```raku\nmy $head = HTTP::Header.new(:h1\u003cv1\u003e, :h2\u003cv2\u003e);\n```\n\nA constructor. Takes name =\u003e value pairs as arguments.\n\n### method header\n\n```raku\nmy $head = HTTP::Header.new(:h1\u003cv1\u003e, :h2\u003cv2\u003e);\nsay $head.header('h1');\n\nmy $head = HTTP::Header.new(:h1\u003cv1\u003e, :h2\u003cv2\u003e);\n$head.header(:h3\u003cv3\u003e);\n```\n\nGets/sets header field.\n\n### method init-field\n\n```raku\nmy $head = HTTP::Header.new;\n$head.header(:h1\u003cv1\u003e);\n$head.init-header(:h1\u003cv2\u003e, :h2\u003cv2\u003e); # it doesn't change the value of 'h1'\nsay ~$head;\n```\n\nInitializes a header field: adds a field only if it does not exist yet.\n\n### method push-header\n\n```raku\nmy $head = HTTP::Header.new;\n$head.push-header( HTTP::Header::Field.new(:name\u003cn1\u003e, :value\u003cv1\u003e) );\nsay ~$head;\n```\n\nPushes a new field. Does not check if exists.\n\n### method remove-header\n\n```raku\nmy $head = HTTP::Header.new;\n$head.header(:h1\u003cv1\u003e);\n$head.remove-header('h1');\n```\n\nRemoves a field of name $field.\n\n### method header-field-names\n\n```raku\nmy $head = HTTP::Header.new(:h1\u003cv1\u003e, :h2\u003cv2\u003e);\nmy @names = $head.header-field-names;\nsay @names; # h1, h2\n```\n\nReturns a list of names of all fields.\n\n### method clear\n\n```raku\nmy $head = HTTP::Header.new(:h1\u003cv1\u003e, :h2\u003cv2\u003e);\n$head.clear;\n```\n\nRemoves all fields.\n\n### method Str\n\nReturns readable form of the whole header section.\n\n### method parse\n\n```raku\nmy $head = HTTP::Header.new.parse(\"h1: v1\\r\\nh2: v2\\r\\n\");\nsay $head.raku;\n```\n\nParses the whole header section.\n\nHTTP::Header::Field\n-------------------\n\nThis module provides a class encapsulating HTTP Message header field.\n\n```raku\nuse HTTP::Header::Field;\nmy $header = HTTP::Header::Field.new(:name\u003cDate\u003e, values =\u003e (123, 456));\n```\n\n### method new\n\nConstructor. Takes these named arguments:\n\n\u003ctable class=\"pod-table\"\u003e\n\u003cthead\u003e\u003ctr\u003e\n\u003cth\u003ekey\u003c/th\u003e \u003cth\u003edescription\u003c/th\u003e\n\u003c/tr\u003e\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e \u003ctd\u003ename\u003c/td\u003e \u003ctd\u003ename of a header field\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003evalues\u003c/td\u003e \u003ctd\u003earray of values of a header field\u003c/td\u003e \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n### method Str\n\nStringifies an HTTP::Header::Field object. Returns a header field in a human (and server) readable form.\n\nHTTP::Request - class encapsulating HTTP request message\n--------------------------------------------------------\n\nModule provides functionality to easily manage HTTP requests.\n\n```raku\nuse HTTP::Request;\nmy $request = HTTP::Request.new(GET =\u003e 'http://www.example.com/');\n```\n\n### method new\n\nA constructor, the first form takes parameters like:\n\n  * method =\u003e URL, where method can be POST, GET ... etc.\n\n  * field =\u003e values, header fields\n\n```raku\nmy $req = HTTP::Request.new(:GET\u003cexample.com\u003e, :h1\u003cv1\u003e);\n```\n\nThe second form takes the key arguments as simple positional parameters and is designed for use in places where for example the request method may be calculated and the headers pre-populated.\n\n### method set-method\n\n```raku\nmy $req = HTTP::Request.new;\n$req.set-method: 'POST';\n```\n\nSets a method of the request.\n\n### method uri\n\n```raku\nmy $req = HTTP::Request.new;\n$req.uri: 'example.com';\n```\n\nSets URL to request.\n\n### method add-cookies\n\n```raku\nmethod add-cookies(HTTP::Cookies $cookies)\n```\n\nThis will cause the appropriate cookie headers to be added from the supplied HTTP::Cookies object.\n\n### method add-form-data\n\n```raku\nmulti method add-form-data(%data, :$multipart)\nmulti method add-form-data(:$multipart, *%data);\nmulti method add-form-data(Array $data, :$multipart)\n```\n\nAdds the form data, supplied either as a `Hash`, an `Array` of `Pair`s, or in a named parameter style, to the POST request (it doesn't make sense on most other request types).\n\nThe default is to use 'application/x-www-form-urlencoded' and 'multipart/form-data' can be used by providing the ':multipart' named argument. Alternatively a previously applied \"content-type\" header of either 'application/x-www-form-urlencoded' or 'multipart/form-data' will be respected and in the latter case any applied boundary marker will be retained.\n\nAs a special case for multipart data if the value for some key in the data is an `Array` of at least one item then it is taken to be a description of a file to be \"uploaded\" where the first item is the path to the file to be inserted, the second (optional) an alternative name to be used in the content disposition header and the third an optional `Array` of `Pair`s that will provide additional header lines for the part.\n\n### method Str\n\nReturns stringified object.\n\n### method parse\n\n```raku\nmethod parse(Str $raw_request --\u003e HTTP::Request:D)\n```\n\nParses raw HTTP request. See `HTTP::Message`\n\nHTTP::Request::Common - Construct common HTTP::Request objects\n--------------------------------------------------------------\n\n```raku\nuse HTTP::Request::Common;\n\nmy $ua       = HTTP::UserAgent.new;\nmy $response = $ua.request(GET 'http://google.com/');\n```\n\nThis module provide functions that return newly created `HTTP::Request` objects. These functions are usually more convenient to use than the standard `HTTP::Request` constructor for the most common requests. The following functions are provided:\n\n### GET $url, Header =\u003e Value...\n\nThe `GET` function returns an `HTTP::Request` object initialized with the \"GET\" method and the specified URL.\n\n### HEAD $url, Header =\u003e Value,...\n\nLike `GET` but the method in the request is \"HEAD\".\n\n### DELETE $url, Header =\u003e Value,...\n\nLike `GET` but the method in the request is \"DELETE\".\n\n### `PUT $url, Header =` Value,..., content =\u003e $content\u003e\n\nLike `GET` but the method in the request is \"PUT\".\n\nHTTP::Response - class encapsulating HTTP response message\n----------------------------------------------------------\n\n```raku\nuse HTTP::Response;\nmy $response = HTTP::Response.new(200);\nsay $response.is-success; # it is\n```\n\nModule provides functionality to easily manage HTTP responses.\n\nResponse object is returned by the .get() method of [HTTP::UserAgent](HTTP::UserAgent).\n\n### method new\n\n```raku\nmy $response = HTTP::Response.new(200, :h1\u003cv1\u003e);\n```\n\nA constructor, takes named arguments:\n\n\u003ctable class=\"pod-table\"\u003e\n\u003cthead\u003e\u003ctr\u003e\n\u003cth\u003ekey\u003c/th\u003e \u003cth\u003edescription\u003c/th\u003e\n\u003c/tr\u003e\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e \u003ctd\u003ecode\u003c/td\u003e \u003ctd\u003ecode of the response\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003efields\u003c/td\u003e \u003ctd\u003eheader fields (field_name =\u0026gt; values)\u003c/td\u003e \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n### method is-success\n\n```raku\nmy $response = HTTP::Response.new(200);\nsay 'YAY' if $response.is-success;\n```\n\nReturns True if response is successful (status == 2xx), False otherwise.\n\nmethod set-code\n---------------\n\n```raku\nmy $response = HTTP::Response.new;\n$response.set-code: 200;\n```\n\nSets code of the response.\n\n### method Str\n\nReturns stringified object.\n\n### method parse\n\nSee `HTTP::Message`.\n\nHTTP::Message - class encapsulating HTTP message\n------------------------------------------------\n\n```raku\nuse HTTP::Message;\nmy $raw_msg = \"GET / HTTP/1.1\\r\\nHost: somehost\\r\\n\\r\\n\";\nmy $mess = HTTP::Message.new.parse($raw_msg);\nsay $mess;\n```\n\nThis module provides a bunch of methods to easily manage HTTP message.\n\n### method new\n\n```raku\nmy $msg = HTTP::Message.new('content', :field\u003cvalue\u003e);\n```\n\nA constructor, takes these named arguments:\n\n\u003ctable class=\"pod-table\"\u003e\n\u003cthead\u003e\u003ctr\u003e\n\u003cth\u003ekey\u003c/th\u003e \u003cth\u003edescription\u003c/th\u003e\n\u003c/tr\u003e\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e \u003ctd\u003econtent\u003c/td\u003e \u003ctd\u003econtent of the message (optional)\u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003efields\u003c/td\u003e \u003ctd\u003efields of the header section\u003c/td\u003e \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n### method add-content\n\n```raku\nmy $msg = HTTP::Message.new('content', :field\u003cvalue\u003e);\n$msg.add-content: 's';\nsay $msg.content; # says 'contents'\n```\n\nAdds HTTP message content. It does not remove the existing value, it concats to the existing content.\n\n### method decoded-content\n\n```raku\nmy $msg = HTTP::Message.new();\nsay $msg.decoded-content;\n```\n\nReturns decoded content of the message (using [Encode](Encode) module to decode).\n\n### method field\n\nSee `HTTP::Header`.\n\n### method init-field\n\nSee `HTTP::Header`.\n\n### method push-field\n\nSee `HTTP::Header`.\n\n### method remove-field\n\nSee `HTTP::Header`.\n\n### method clear\n\n```raku\nmy $msg = HTTP::Message.new('content', :field\u003cvalue\u003e);\n$msg.clear;\nsay ~$msg; # says nothing\n```\n\nRemoves the whole message, both header and content section.\n\n### method parse\n\n```raku\nmy $msg = HTTP::Message.new.parse(\"GET / HTTP/1.1\\r\\nHost: example\\r\\ncontent\\r\\n\");\nsay $msg.raku;\n```\n\nParses the whole HTTP message.\n\nIt takes the HTTP message (with \\r\\n as a line separator) and obtains the header and content sections, creates a `HTTP::Header` object.\n\n### method Str\n\nReturns HTTP message in a readable form.\n\nAUTHOR\n======\n\n  * Filip Sergot\n\nSource can be located at: https://github.com/raku-community-modules/HTTP-UserAgent . Comments and Pull Requests are welcome.\n\nCOPYRIGHT AND LICENSE\n=====================\n\nCopyright 2014 - 2022 Filip Sergot\n\nCopyright 2023 - 2025 The Raku Community\n\nThis library is free software; you can redistribute it and/or modify it under the MIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Fhttp-useragent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraku-community-modules%2Fhttp-useragent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Fhttp-useragent/lists"}