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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kakami okatsu

Pages: [1]
1
Network / Re: Download File Http
« on: January 26, 2013, 12:26:05 am »
Thank you so much! The problem was on my code.
Your code solve the error!

2
Network / Download File Http
« on: January 20, 2013, 03:19:53 pm »
Ih all I'm an italian student.
In my project I want to download an image by a url. Everything is fine until I try to download an image bigger than 4KB. The problem (i think) is the max size of string.
I'll post the code. Maybe there is an error!
string DownloadHtml(string Url){  
         //Split the url (Why I have to do this??)
         unsigned EndBase = Url.find("/",7); //Jump over the "http://" and search for another "/"
         string BaseURL = Url.substr(0,EndBase);
         string Page = Url.substr(EndBase);
         // Create a new HTTP client
         sf::Http http;

         http.setHost(BaseURL);

         // Prepare a request
         sf::Http::Request request(Page);

         // Send the request
         sf::Http::Response response = http.sendRequest(request);
         // Check the status code and display the result
         sf::Http::Response::Status status = response.getStatus();
         if (status == sf::Http::Response::Ok)
         {
                 return response.getBody();
         }
         else
         {
                 std::cout << "Error " << status << std::endl;
         }
}

//Load the image from Url into sf::Texture
sf::Texture GetCopertina(string Url){
        sf::Texture Txt;
        string FileCopertina = DownloadHtml(Url);
        long int Dim = FileCopertina.length();
        Txt.loadFromMemory(FileCopertina.c_str(),Dim);
        return Txt;
}
 
It's possible to download a file with http and sfml?

Pages: [1]
anything