Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Get content type

Tags:

http

I have a program that is supposed to interact with a web server and retrieve a file containing structured data using http and cgi. I have a couple questions:

  1. The cgi script on the server needs to specify a body right? What should the content-type be?
  2. Should I be using POST or GET?
  3. Could anyone tell me a good resource for reading about HTTP?
like image 690
Jordan Avatar asked Nov 28 '25 20:11

Jordan


2 Answers

If you just want to retrieve the resource, I’d use GET. And with GET you don’t need a Content-Type since a GET request has no body. And as of HTTP, I’d suggest you to read the HTTP 1.1 specification.

like image 65
Gumbo Avatar answered Nov 30 '25 22:11

Gumbo


  1. The content-type specified by the server will depend on what type of data you plan to return. As Jim said if it's JSON you can use 'application/json'. The obvious payload for the request would be whatever data you're sending to the client.

  2. From the servers prospective it shouldn't matter that much. In general if you're not expecting a lot of information from the client I'd set up the server to respond to GET requests as opposed to POST requests. An advantage I like is simply being able to specify what I want in the url (this can't be done if it's expecting a POST request).

  3. I would point you to the rfc for HTTP...probably the best source for information..maybe not the most user friendly way to get your answers but it should have all the answers you need. link text

like image 31
IaCoder Avatar answered Nov 30 '25 22:11

IaCoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!