Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralC# and PostgreSQL Pin
tashee21-Dec-12 2:22
tashee21-Dec-12 2:22 
GeneralRe: C# and PostgreSQL Pin
Keith Barrow21-Dec-12 3:02
professionalKeith Barrow21-Dec-12 3:02 
QuestionC#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)) Pin
S Akshay20-Dec-12 23:54
S Akshay20-Dec-12 23:54 
AnswerRe: C#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)) Pin
Dave Kreskowiak21-Dec-12 4:12
mveDave Kreskowiak21-Dec-12 4:12 
GeneralRe: C#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)) Pin
S Akshay21-Dec-12 4:42
S Akshay21-Dec-12 4:42 
GeneralRe: C#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)) Pin
Dave Kreskowiak21-Dec-12 4:53
mveDave Kreskowiak21-Dec-12 4:53 
QuestionCapture HttpRequest from Fiddler or WinpCap, then reconstruct a HttpRequest object? Pin
devvvy20-Dec-12 14:50
devvvy20-Dec-12 14:50 
AnswerRe: Capture HttpRequest from Fiddler or WinpCap, then reconstruct a HttpRequest object? Pin
Super Lloyd20-Dec-12 18:19
Super Lloyd20-Dec-12 18:19 
what's the problem with that???
I don't quite see the so I just pasted below some code to create a webrequest...

C#
var wr = (HttpWebRequest)WebRequest.Create(uri);
SetHeader(wr, "GET", new Dictionary<tring,string> { {  "Content-Type", "x-text" }, ..});
if (stream != null && stream.Length > 0)
    using(var ws = wr.GetRequestStream())
        Copy(stream, ws, length);

...
public static void SetHeader(HttpWebRequest req, string method, Dictionary<string, string> headers)
{
req.Method = method;
foreach (var kv in headers)
{
	var k = kv.Key;
	var v = kv.Value;
	switch (k)
	{
		case "User-Agent":
			req.UserAgent = v;
			break;
		case "Host":
			break;
		case "Accept":
			req.Accept = v;
			break;
		case "Proxy-Connection":
		case "Connection":
			req.KeepAlive = (v ?? "").ToLower() == "keep-alive";
			break;
		case "Referer":
			req.Referer = v;
			break;
		case "Content-Length":
			req.ContentLength = reqSrc.ContentLength;
			break;
		case "Content-Type":
			req.ContentType = v;
			break;
		case "If-Modified-Since":
			req.IfModifiedSince = DateTime.Parse(v);
			break;
		default:
			req.Headers.Add(k, v);
			break;
	}
}
static void Copy(Stream src, Stream dst, int len)
{
	var buff = new byte[1 << 12];
	int nread = 0;
	int toRead = buff.Length > len ? len : buff.Length;
	while ((nread = src.Read(buff, 0, toRead)) > 0 && len > 0)
	{
		dst.Write(buff, 0, nread);
		len -= nread;
		toRead = buff.Length > len ? len : buff.Length;
	}
}

A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.

GeneralRe: Capture HttpRequest from Fiddler or WinpCap, then reconstruct a HttpRequest object? Pin
devvvy21-Dec-12 23:01
devvvy21-Dec-12 23:01 
Questionsending messages with smart bro using c# Pin
Glendonz20-Dec-12 6:23
Glendonz20-Dec-12 6:23 
AnswerRe: sending messages with smart bro using c# Pin
jschell20-Dec-12 8:37
jschell20-Dec-12 8:37 
GeneralRe: sending messages with smart bro using c# Pin
Glendonz20-Dec-12 16:21
Glendonz20-Dec-12 16:21 
GeneralRe: sending messages with smart bro using c# Pin
jschell22-Dec-12 13:52
jschell22-Dec-12 13:52 
GeneralRe: sending messages with smart bro using c# Pin
Glendonz30-Dec-12 5:36
Glendonz30-Dec-12 5:36 
Questionremobjects and simular products Pin
Menelaos Vergis20-Dec-12 6:22
Menelaos Vergis20-Dec-12 6:22 
AnswerRe: remobjects and simular products Pin
Super Lloyd20-Dec-12 18:11
Super Lloyd20-Dec-12 18:11 
GeneralRe: remobjects and simular products Pin
Menelaos Vergis23-Dec-12 22:00
Menelaos Vergis23-Dec-12 22:00 
GeneralRe: remobjects and simular products Pin
Super Lloyd24-Dec-12 3:40
Super Lloyd24-Dec-12 3:40 
QuestionPls help me with repeater control....!! Pin
Yasir88720-Dec-12 4:24
Yasir88720-Dec-12 4:24 
RantRe: Pls help me with repeater control....!! Pin
Richard Deeming20-Dec-12 4:46
mveRichard Deeming20-Dec-12 4:46 
GeneralRe: Pls help me with repeater control....!! Pin
Yasir88720-Dec-12 6:20
Yasir88720-Dec-12 6:20 
GeneralRe: Pls help me with repeater control....!! Pin
Richard Deeming20-Dec-12 6:50
mveRichard Deeming20-Dec-12 6:50 
GeneralRe: Pls help me with repeater control....!! Pin
Yasir88720-Dec-12 7:02
Yasir88720-Dec-12 7:02 
GeneralRe: Pls help me with repeater control....!! Pin
Richard Deeming20-Dec-12 7:12
mveRichard Deeming20-Dec-12 7:12 
GeneralRe: Pls help me with repeater control....!! Pin
Yasir88721-Dec-12 6:35
Yasir88721-Dec-12 6:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.