Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
f4b01aea
Commit
f4b01aea
authored
26 years ago
by
Mirar (Pontus Hagland)
Browse files
Options
Downloads
Patches
Plain Diff
helper functions
Rev: lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:1.1
parent
cc60ccf3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Protocols.pmod/HTTP.pmod/module.pmod
+45
-0
45 additions, 0 deletions
lib/modules/Protocols.pmod/HTTP.pmod/module.pmod
with
45 additions
and
0 deletions
lib/modules/Protocols.pmod/HTTP.pmod/module.pmod
0 → 100644
+
45
−
0
View file @
f4b01aea
//! module Protocols
//! submodule HTTP
//! method string get_url(string url)
//! Sends a HTTP GET request to the server in the URL
//! and returns the created and initialized <ref>Query</ref> object.
//! 0 is returned upon failure.
//!
//! method array get_url_nice(string url)
//! Returns an array of ({content_type,data})
//! after calling the requested server for the information.
//! 0 is returned upon failure.
object get_url(string url)
{
object con=master()->resolv("Protocols")["HTTP"]["Query"]();
string prot="http",host;
int port=80;
string query;
sscanf(url,"%[^:/]://%[^:/]:%d/%s",prot,host,port,query) == 4 ||
(port=80,sscanf(url,"%[^:/]://%[^:/]/%s",prot,host,query)) == 3 ||
(prot="http",sscanf(url,"%[^:/]:%d/%s",host,port,query)) == 3 ||
(port=80,sscanf(url,"%[^:/]/%s",host,query)) == 2 ||
(host=url,query="/");
if (prot!="http")
error("Protocols.HTTP can't handle %O or any other protocol then HTTP\n",
prot);
con->sync_request(host,port,
"GET "+query+" HTTP/1.0",
(["user-agent":
"Mozilla/4.0 compatible (Pike HTTP client)"]));
if (!con->ok) return 0;
return con;
}
array(string) get_url_nice(string url)
{
object c=get_url(url);
return c && ({c->headers["content-type"],c->data()});
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment