Solved

Conecting directly to port 80...

Posted on 1998-10-05
5
188 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

810 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