Solved

Conecting directly to port 80...

Posted on 1998-10-05
5
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

733 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