Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Today's Messages (off)  | Unanswered Messages (on)

Forum: U++ Core
 Topic: Some modifications for WebSocket only as Client
Some modifications for WebSocket only as Client [message #50325] Thu, 20 September 2018 13:50
kasome is currently offline  kasome
Messages: 76
Registered: July 2008
Location: Taiwan
Member
Hi, all

Here's some modifications for WebSocket, and I only test WebSocket as Client,and hope that helps.


In upp\uppsrc\Core\WebSocket.cpp

Modify
void WebSocket::SendRequest()
{
	........................................
	for(int i = 0; i < 20; i++)
		h.Cat(Random());
	........................................
}


to
void WebSocket::SendRequest()
{
	........................................
	for(int i = 0; i < 16; i++)
		h.Cat(Random());
	........................................
}


Because from https://tools.ietf.org/html/rfc6455

Quote:

The value of this header field MUST be a nonce consisting of a randomly selected 16-byte value that has been base64-encoded.
NOTE: As an example, if the randomly selected value was the sequence of bytes 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10, the value of the header field would be "AQIDBAUGBwgJCgsMDQ4PEC=="


============================================================ =====================================================

Modify
void WebSocket::Close(const String& msg, bool wait_reply)
{
	........................................
	SendRaw(CLOSE|FIN, msg);
	........................................
}

void WebSocket::FrameData()
{
	........................................
		SendRaw(PONG|FIN, data);
	........................................
}



to
void WebSocket::Close(const String& msg, bool wait_reply)
{
	........................................
	SendRaw(CLOSE|FIN, msg, MASK);
	........................................
}

void WebSocket::FrameData()
{
	........................................
		SendRaw(PONG|FIN, data, MASK);
	........................................
}



Because from https://tools.ietf.org/html/rfc6455

Quote:

A client MUST mask all frames that it sends to the server (Note that masking is done whether or not the WebSocket Protocol is running over TLS)
The server MUST close the connection upon receiving a frame that is not masked. In this case, a server MAY send a Close frame with a status code of 1002 (protocol error)
A server MUST NOT mask any frames that it sends to the client. A client MUST close a connection if it detects a masked frame.


[Updated on: Thu, 20 September 2018 14:04]

Report message to a moderator

Forum: Newbie corner
 Topic: print the Http Request before sending it
print the Http Request before sending it [message #50319] Tue, 18 September 2018 15:44
Xemuth is currently offline  Xemuth
Messages: 6
Registered: August 2018
Location: France
Promising Member
Hello Everyone,

I'm looking for a way to show the request of HttpRequest object before Execute it.

#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{

	HttpRequest test("http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl");
	test.Post("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:hs='http://www.holidaywebservice.com/HolidayService_v2/'><soapenv:Body><hs:GetHolidaysForMonth><hs:year>2018</hs:year><hs:countryCode>UnitedStates</hs:countryCode><hs:month>11</hs:month></hs:GetHolidaysForMonth></soapenv:Body></soapenv:Envelope>");
	Cout() << test.MyRequestAtString();  //Looking for something like that !
	Cout() << test.Execute();
	test.Close();
	
}


It will help me to determine why I have no response.

Thanks in advance !
Forum: Mac OSX
 Topic: New theide for MacOSX
New theide for MacOSX [message #50311] Mon, 17 September 2018 15:47
mirek is currently offline  mirek
Messages: 11441
Registered: November 2005
Ultimate Member
https://drive.google.com/open?id=1ZjKFcjcUXYoY2Ga7iXP9oBTGaZ lgHXuW

This should work mostly out of box - with xcode 9 (or just commandline tools) installed, it should setup CLANG build method and offer to checkout U++ sources from svn.

Mirek



Current Time: Fri Sep 21 04:53:52 CEST 2018

Total time taken to generate the page: 0.01256 seconds