Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help with making a POST request  (Read 10674 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Help with making a POST request
« Reply #15 on: July 21, 2011, 03:31:24 pm »
I think that what's contained in the body is simply a default, human-readable page that allows the user to know what happened in case the browser does not implement the redirection. But if you want to implement the redirection, you should rather look into the header's fields -- I think the new URL is under "Location" for a redirection.

Code: [Select]
std::string newUri = response.GetField("Location");
Laurent Gomila - SFML developer

Joshua Flynn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Help with making a POST request
« Reply #16 on: July 29, 2011, 10:28:06 pm »
Quote from: "Laurent"
I think that what's contained in the body is simply a default, human-readable page that allows the user to know what happened in case the browser does not implement the redirection. But if you want to implement the redirection, you should rather look into the header's fields -- I think the new URL is under "Location" for a redirection.

Code: [Select]
std::string newUri = response.GetField("Location");


Sorry I took some time. Was developing the program.

Is there a way to see the header fields (like accessing it like a string), so I can see what's inside and thus know which field to reference it to?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Help with making a POST request
« Reply #17 on: July 29, 2011, 10:45:10 pm »
Quote
Is there a way to see the header fields

No.
Laurent Gomila - SFML developer

Joshua Flynn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Help with making a POST request
« Reply #18 on: July 31, 2011, 09:37:09 am »
Quote from: "Laurent"
Quote
Is there a way to see the header fields

No.


Okay. Is there any way to know what the header fields contain? Given there is no way I can guess what they contain.

And, is it possible to access/download images using the Get method (or something similar)?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Help with making a POST request
« Reply #19 on: July 31, 2011, 10:13:23 am »
Quote
Is there any way to know what the header fields contain?

How is it different from your previous question? :D

Quote
And, is it possible to access/download images using the Get method (or something similar)?

Yes, they are like any other web page. You just have to interpret the body differently, based on the MIME type returned in the header.
Laurent Gomila - SFML developer

Joshua Flynn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Help with making a POST request
« Reply #20 on: August 02, 2011, 04:40:32 pm »
Quote from: "Laurent"

Yes, they are like any other web page. You just have to interpret the body differently, based on the MIME type returned in the header.


So assuming I knew what to expect (the image is a GIF, two versions, one is static, one is multiple images in a loop), and I can obtain the link for it's location, how would I download the image, and save it as a file?

Quote from: "Laurent"

How is it different from your previous question? :D


I suppose I was trying to somehow broaden it. Is there a tool that can access the header? I mean, how do you know a location exists inside the header if it's not possible to see it before?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Help with making a POST request
« Reply #21 on: August 02, 2011, 04:49:37 pm »
Quote
So assuming I knew what to expect (the image is a GIF, two versions, one is static, one is multiple images in a loop), and I can obtain the link for it's location, how would I download the image, and save it as a file?

You build a GET request with the image location, and you directly dump the body of the response to a file. Normally.

Quote
Is there a tool that can access the header? I mean, how do you know a location exists inside the header if it's not possible to see it before?

You're supposed to know which header field to retrieve (after reading carefully the HTTP RFC).
Laurent Gomila - SFML developer

Joshua Flynn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Help with making a POST request
« Reply #22 on: August 05, 2011, 09:22:58 am »
Quote from: "Laurent"

You build a GET request with the image location, and you directly dump the body of the response to a file. Normally.


Okay. Sounds good and straight forward enough to me.

Quote from: "Laurent"

You're supposed to know which header field to retrieve (after reading carefully the HTTP RFC).


I'll read through that.

It gives me the impression - is SFML capable of sending emails? And if so, how would you configure it to do so?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Help with making a POST request
« Reply #23 on: August 05, 2011, 09:41:48 am »
Quote
It gives me the impression - is SFML capable of sending emails? And if so, how would you configure it to do so?

No no. E-mails have their own protocol (SMTP, for sending), it's a totally different thing and SFML doesn't implement that.
Laurent Gomila - SFML developer

Joshua Flynn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Help with making a POST request
« Reply #24 on: August 05, 2011, 01:09:26 pm »
Quote from: "Laurent"

No no. E-mails have their own protocol (SMTP, for sending), it's a totally different thing and SFML doesn't implement that.


Okay. Last couple of questions. For writing the images, would I use normal (text) or binary mode for that?

And, GET response returns things like '%3f' to represent question marks, etc - what representative method is this (is there a list of all these I can use)? And is there some way of automatically converting one from the other without having to implement my own functions?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Help with making a POST request
« Reply #25 on: August 05, 2011, 01:26:18 pm »
Quote
Okay. Last couple of questions. For writing the images, would I use normal (text) or binary mode for that?

I have no idea, that's where my knowledge ends, sorry ;)
Maybe you'll need to decode the response body first, it might be encoded differently.

Quote
And, GET response returns things like '%3f' to represent question marks, etc - what representative method is this (is there a list of all these I can use)? And is there some way of automatically converting one from the other without having to implement my own functions?

You should have a look at this:
http://en.wikipedia.org/wiki/Percent-encoding

I think you should read articles/tutorials about the concepts involved here, since you're new to many of them. A good global understanding is necessary before trying to implement things.
Laurent Gomila - SFML developer

 

anything