Solved

Conecting directly to port 80...

Posted on 1998-10-05
5
189 Views
Last Modified: 2013-12-25
Hello,
Not sure if this is the proper place for this question but...
I need to create a script that connects to port 80 of a specfic server.
The conecting part is not the problem. But when I try to "talk" to the server to retrieve a site. The script would behave as a browser, retrieving the page and any images asociated withit.
So the question really is:
How di I format a proper request method to a web server?
I tried:
get index.html http/1.1
get / http/1.1
and none worked. I tried reading the RFC for http1.1 and it was just to technical for this semi-geek.
All I need to do is retrieve the main file and parce out anything that would be in font bigger than 3 or in bold...

Thanks for your help
0
Comment
Question by:sinner052397
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:mouatts
ID: 1828926
Your first answer is almost correct if you aren't going via a proxy. If you are you must use the absolute URL and not the relative one.

I think that http should be HTTP.

Make sure that the line is terminated with a CR and LF


Steve
0
 

Author Comment

by:sinner052397
ID: 1828927
How would a fully correct answer look like?
From a telnet session, without a proxy, I tried:

get index.html HTTP/1.1   and I got HTTP/1.1 400 Bad Request
get / HTTP/1.1   and I got HTTP/1.1 400 Bad Request
get get http://www.sf.cl   HTTP/1.1 and I got  HTTP/1.1 400 Bad Request

My other question is, if you do not know the name of the first page, what is the proper call? If I connect to cnn.com how do I know wether to ask for inex.html index.htm default.htm default.asp, etc...
could it be because I am trying this through a telnet session as oposed to throug the script and thus not emulating a browser?

Thanks again,
Marcelo


0
 

Author Comment

by:sinner052397
ID: 1828928
I also tried:
get /index.html HTTP/1.1
GET index.html HTTP/1.1
GET /index.html HTTP/1.1
and none worked...

0
 
LVL 7

Accepted Solution

by:
faster earned 150 total points
ID: 1828929
GET / HTTP/1.0\r\n
\r\n
0
 
LVL 7

Expert Comment

by:faster
ID: 1828930
In short, you need 1 empty line.  The complete request format is:

Reguest line\r\n
header1: value1\r\n
header2: value2\r\n
.
\r\n

\r\n can also be replaced with \n, but \r\n is better, because that is the http standard.
Headers are optional for http 1.0, but in http 1.1, You must have a "Host" header, the host is the name of the server, for example:

Host: www.microsoft.com\r\n
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
get remote physical servers and platforms 5 54
home folder path for users 4 85
copy-item script help 15 80
React or Angular? 6 80
Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question