The progress this week was relatively slow. We have been facing some problems with the implementation of the tasks. Though, the problems at first seem minute and trivial, yet, when it comes to real implementation, complexity builds up!

Before starting on this week tasks, we were first required to improve our previous code. These improvements included error checking (paranoid error checking), properly structuring the code in form of functions, and adding documentation to our classes and functions. After that, we stared working on the new tasks.

The main feature that I focused on was to receive a post request from a third party that contains an uploaded archive file, extract the file to a temporary directory determined by the user session ID. However, my lack of understanding of basic server functionality held me back for a while! I thought it was better to first understand how does Witty handles uploading files. Once I (kind of) figured that out, my supervisor Dr. Shawn told me that all what I have done was completely wrong! Then he explained to me how a server handles uploaded files and what really spool file name is, and why I should not (steal) it for our purpose. I spent the rest of the day testing and deepening my understanding by applying it. I created an HTML page that has a form with a POST method (to represent a general third party request to the application). The form has a file field to upload a file and is then posted to Witty WResource, which will then handle it.

My second problem was to start a WApplication from within a WResoruce. To explain further, our WApplication should start with a POST request (with an uploaded file) instead of GET request as it normally starts. My first thought was to handle the request from a WResource, however, redirecting then to the application was a problem as no instance of the WApplication has been created yet! After doing a bit of a research and referring to this post, I found out the WEnvironment can be used to get the POST request parameters sent to the WApplication. The only problem I faced with WEnvironment is that it does not have a uploadedFiles() function as the request can be handled in the WResoruce. I then decided to post my problem on Witty forums, but I haven’t got a reply yet!

One solution that actually worked is to return the response from the WResoruce – after receiving and extracting the archive folder – with (3xx) status and create a “Location” header with the application URL. The only problem with this method is that the application needs to receive the path to the extracted folder. And from what I found out, is that this path will have to be sent as GET parameter (in the URL) and cannot be sent as POST parameter when redirecting!

I think I will put this problem on hold for now if I couldn’t solve it and continue to finish the task and integrate it with Sumia’s part. Since most of the week was spent on searching and trying to solve problems, actual progress was quite little. Therefore, this week I will do my best to try to get some things done.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.