GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — httpc-cli/request.js at master · sarthak3154/httpc-cli

Expand file tree

/

request.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
40 lines (36 loc) · 1.36 KB
/

request.js

Copy path

File metadata and controls

40 lines (36 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Util = require('./util');
const fs = require('fs');
exports.getRequestObject = (url, args) => {
const url_args = Util.getURLProperties(url);
const request = {
method: args.method,
h: args.h,
args: url_args
};
if (args.hasOwnProperty('d')) request.d = args.d;
else if (args.hasOwnProperty('f')) request.f = args.f;
return request;
};
exports.createHTTPRequest = (request) => {
let http_request;
if (request.method === GET_CONSTANT) {
http_request = 'GET ';
} else if (request.method === POST_CONSTANT) {
http_request = 'POST ';
}
http_request += (request.args.hasOwnProperty('pathname') ? request.args.pathname : '/')
+ (!Util.isEmpty(request.args.query) ? ('?' + request.args.href.toString().split('?')[1]) : '')
+ ' HTTP/1.0\r\nHost: ' + request.args.host + `\r\nUser-Agent: ${USER_AGENT}\r\n`;
if (request.h.length > 0) {
request.h.forEach(value => {
http_request += (value + '\r\n');
})
}
if (request.hasOwnProperty('d') || request.hasOwnProperty('f')) {
const body = (request.hasOwnProperty('d') ? request.d : fs.readFileSync(request.f, 'utf8').trim());
http_request += ('Content-Length: ' + body.length + '\r\n\r\n');
http_request += (body + '\r\n');
}
http_request += '\r\n';
return http_request;
};
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.