<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw='http://wellformedweb.org/CommentAPI/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rl='http://www.purl.org/RESTLog/'>
  <channel>
    <title>RESTLog Client Details</title>
    <link>http://wellformedweb.org/news/10</link>
    <description>
&lt;p&gt;The source for RESTLogClient is contained in two files: &lt;code&gt;PostEditor.cs&lt;/code&gt; which handles all
the user-interface and &lt;code&gt;ContentManager.cs&lt;/code&gt; which handles the web interface.
The lowest level inteface in &lt;code&gt;ContentManager.cs&lt;/code&gt; is RESTLogPublisher and it 
handles most of that web interface. The public members of RESTLogPublisher are:
&lt;/p&gt;
&lt;div class="example"&gt;&lt;pre&gt;&lt;code&gt;public class RESTLogPublisher {
  .
  .
  .
  public void PublishNewItem(string filename) {
    ..
  }

  public void PublishEditedItem(
    string filename, 
    int itemID) 
  {
    ...
  }

  public void DeleteItem(int itemID) {
    ...
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The three public methods of RESTLogPublisher are DeleteItem, PublishEditedItem and PublishNewItem.
These in turn use one of the two private functions SimpleRequest and Publish.
Now SimpleRequest is just that, a simple HTTP request that has no content.
You hand it the URL and the HTTP verb and it does the work. 
&lt;/p&gt;&lt;p&gt;
Publish performs HTTP requests that send content in the request, so it needs to be 
passed the verb, the URI, and the name of the file that contains the 
content to be sent. Note that because of the limited repertoire of RESTLog that
many things in Publish are hard-coded, for example the timeout is set to 30 seconds and
the content type is always 'text/xml'. The comprehensive HTTP support in the .Net framework
makes this a fairly simple, if verbose, exercise.
&lt;/p&gt;
&lt;div class="example"&gt;&lt;pre&gt;&lt;code&gt;public class RESTLogPublisher {
  .
  .
  .
  private void Publish(
    string filename, 
    string verb, 
    string url) 
  {
    WebRequest req = WebRequest.Create(url);
    req.ContentType = "text/xml";
    req.Credentials = new NetworkCredential(
       config_.user_, config_.password_
    );
    FileStream inFile = new FileStream(
       filename, FileMode.Open
    );
    int fileSize = (int)inFile.Length;
    byte[] data = new byte[fileSize];
    inFile.Read(data, 0, fileSize);
    inFile.Close();
    req.ContentLength = fileSize;
    req.Method = verb;
    req.Timeout = 30000;
    Stream upstream = req.GetRequestStream();
    upstream.Write(data, 0, fileSize);
    upstream.Close();
    WebResponse resp = req.GetResponse();
    resp.Close();
  }

  private void SimpleRequest(
    string verb, 
    string url) 
  {
    WebRequest req = WebRequest.Create(url);
    req.Credentials = new NetworkCredential(
      config_.user_, 
      config_.password_
    );
    req.Method = verb;
    req.Timeout = 30000;
    WebResponse resp = req.GetResponse();
    resp.Close();
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next I'll build a list of new features to add to RESTLog. Over
the next few weeks I'll add them one
at a time to the server and client.&lt;/p&gt;


</description>
    <dc:creator>BitWorking, Inc</dc:creator>
  </channel>
</rss>



