Using Http Client

This week I have done some Http post request to post the data input by the user to the WResource(). In this web application, the user can  perform a few task. The key task is:

  • To revoke a certificate by the push of a button.
  • To renew a certificate by entering the period or new expiry date.
  • To create a new certificate.

for the three task listed, I decided to use the Http::Client post method to post the data input by the user into the resource for processing. I added the data to the message body  of the post request. Then the resource will get the data from the request message body and respond with the result on the response body. When the Http::Client receive a response. I will get the data from the response body and present it to the user or notify the user when the task is complete and user will be redirect back to the main page after the task have been carried out.

sorting out data from response body:

Reviewing the get request performed in the main page, I was able to get the list of certificate from the response body and was able to display it on the command. Then I simply used a WText to display on the main page. The data appear on the main page are on the same line and do not have space in between. It is raw and hard to be digested by a user. Dr. Shawn suggested that we can use WTable to sort the data out because the functionality of the WTable is dynamic and easy to be used. I started using loop to set up rows. This method is not the best way of doing it because the number of rows of the table will be fixed and cannot be add or reduced. I will find another way to set up table row that can easily add and subtract the row of the table. Besides the table, the data is also being processed  using stringstream. With the help from Islam, I was able to list the data out for the user.

Radio button
Checkbox or radiobutton??

This is the question when I wanted to add option to the list of certificate. But after a quick peak at the Wt library, it is obvious that radio button is a better choice. This is because radio button can be grouped to gather by the WButtonGroup class. I think this is more convenient to pinpoint and manipulate the selection of the user. However, user are not able to select more than one radio button at the same time. I will try to find a solution to this problem and develop a better system to response to the user. I used simple loop to add radio button to each certificate and add these button to the button group with different Id. For now I am still struggling to get the particular name of the certificate once the radio button is selected. I tried to use the elementAt(row, collumn) function of the table to retrieve the data input at the specific row but sadly it return the type as WTableCell.


The function of an email in this application is to email the user the certificate created and maybe the information of renew and revoke. I have roughly explored  Wt SMTP Client library (Wt::Mail). SMTP Client is a client that send email to the SMTP host. This client is quite easy to build with the help of the example in the Wt documentation. I have constructed the Mail::Client on the create form. I did not understand SMTP host well enough so I set It to selfhost and will deepen my knowledge in this. I am able to get the data form the response body to be added to the Mail::Message body. To me, the implementation of the Wt::Mail is quite straightforward for now.


Previously me and Tze Hao thought of attaching the certificate document on the email and send it directly to the  user to be imported to their browser. After checking the functions of Wt::Mail, I think it would be the best if we send the link to the user and have them download and import the certificate. I am still trying to perform addAttachment() function  to add attachments to email for user.



Leave a Reply

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