Jump to content

HTTP Request

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 298 posts
Hello all,

I was wanting to know how to make a HTTP request. I know the structure of it (header, get, post, etc.) but don't actually know how to make it.

Is there a program I use, or a file type, or a server, etc. (May sound stupid but I'd like to know).

Thank You.

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
The HTTP protocol can be used in many ways, and is simply just plaintext. You need something to implement the protocol, to be able to traverse or do anything useful with it.

You can open up your command prompt and run this:
telnet www.google.com 80

Once you are connected, you can write the header to the website. An example is this:
GET / HTTP/1.1 [clrf]
Host: www.google.com [clrf]
[clrf]

CLRF being the enter key of course. I'm not sure what you're wanting to do with it, "Make" isn't specific.

Programatically, [link: libcurl] could provide easy implementation, but there are too many language specific things.

#3
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 298 posts
So, what about an implementation for SMTP or FTP?

Thanks for the help.

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
To connect to these, you'll basically just be required to use C++'s functions (fsockopen, and alike). There are many examples on the web:
[Link: http://www.codeproje...ientclass.aspx]
[Link: C++ SMTP Example - Stack Overflow]

Of course other languages can use their own libraries; Python and Perl (in CPAN) should provide modules for FTP or alike. There really aren't any major APIs out there, as it's just mid level networking stuff.

#5
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 298 posts
recv is the recieving function, what is the sending function?

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
sendto() will do:

ssize_t sendto(int socket, const void *message, size_t length,
int flags, const struct sockaddr *dest_addr,
socklen_t dest_len)

Why not look at all the goodies of the socket.h you're including?:
[Link: http://www.opengroup.../socket.h.html]