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
b8ea69df
Commit
b8ea69df
authored
26 years ago
by
Mirar (Pontus Hagland)
Browse files
Options
Downloads
Patches
Plain Diff
sync method added
Rev: lib/modules/Protocols.pmod/HTTP.pmod/Query.pike:1.2
parent
2102dc67
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
+37
-1
37 additions, 1 deletion
lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
with
37 additions
and
1 deletion
lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
+
37
−
1
View file @
b8ea69df
...
...
@@ -42,7 +42,8 @@
**! Errno copied from the connection.
**!
**! variable mapping headers
**! Headers as a mapping.
**! Headers as a mapping. All header names are in lower case,
**! for convinience.
**!
**! variable string protocol
**! Protocol string, ie "HTTP/1.0".
...
...
@@ -373,8 +374,41 @@ object thread_request(string server,int port,string query,
if (server1) server=server1; // cheaty, if host doesn't exist
// prepare the request
if (!data) data="";
if (!headers) headers="";
else if (mappingp(headers))
{
headers=mkmapping(Array.map(indices(headers),lower_case),
values(headers));
if (data!="") headers->content_length=strlen(data);
headers=headers_encode(headers);
}
request=query+"\r\n"+headers+"\r\n"+data;
conthread=thread_create(connect,server,port);
return this_object();
}
object sync_request(string server,int port,string query,
void|mapping|string headers,void|string data)
{
// start open the connection
con=Stdio.File();
if (!con->open_socket())
error("HTTP.Query(): can't open socket; "+strerror(con->errno)+"\n");
string server1=dns_lookup(server);
if (server1) server=server1; // cheaty, if host doesn't exist
// prepare the request
if (!data) data="";
...
...
@@ -392,6 +426,8 @@ object thread_request(string server,int port,string query,
request=query+"\r\n"+headers+"\r\n"+data;
connect(server,port);
return this_object();
}
...
...
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