Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

marky-b

Member Since 04 Oct 2011
Offline Last Active Aug 27 2012 07:51 PM
-----

Topics I've Started

.NETMF Toolbox HTTP Client issue

24 November 2011 - 04:48 AM

I working with Stefan's .NETMF Toolbox to scrape some info from a page.

I created a really basic "web service" of sorts that uses the magic of PHP to fetch and present the number of unread emails in my Gmail account (its located at http://markweinmann.com/gmail.php)

When i hit the page manually, the source of the page is "367" (or how ever many unread emails i have), but when i use the .NETMF Toolbox with HTTP Client, the response body i get back is "\r\n\r\n3\r\n376\r\n0\r\n\r\n".

here is the code i'm using:
// Create a new web session
HTTP_Client webSession = new HTTP_Client("markweinmann.com");
// Request source code
HTTP_Client.HTTP_Response response = webSession.Get("/gmail.php");
// Retrieve page source
string source = response.ResponseBody.ToString();
// Debug
Debug.Print(source);

Any ideas why the response is different between browser and code?

Mark

String manipulation in .net 4.1 Micro

13 October 2011 - 01:04 AM

I am attempting to do some string manipulation (below), but I came to find that some of my favorite methods and types aren't supported by .NETMF :(

I first attempted:

string output = string.Format("It is {0} {1} {2} {3}", str0, str1, str2, str3);
but this clearly failed, as string.Format is missing from 4.1.

I then decided I was going to try and roll my own extension method, but came to find out that stringbuilder (more specifically "replace") is missing as well.

I see that Valkyrie-MT as an extension method class he uses for some of his projects, which includes:

public static string Replace(this string stringToSearch, char charToFind, char charToSubstitute)
{
    // Surely there must be nicer way than this?
    char[] chars = stringToSearch.ToCharArray();
    for (int i = 0; i < chars.Length; i++)
        if (chars[i] == charToFind) chars[i] = charToSubstitute;

    return new string(chars);
}
but I would have to think there is a better way to do this in .NETMF (no offense Valkyrie) ;)

Any thoughts? Should I be looking at 4.2?

Mark

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.