Exemple #1
0
/* Parse the URI from the given transaction (which is assumed to be in request
 * phase) and look for the "/" beginning the PATH. If not found, ist2(0,0) is
 * returned. Otherwise the pointer and length are returned.
 */
struct ist http_get_path(const struct ist uri)
{
	const char *ptr, *end;

	if (!uri.len)
		goto not_found;

	ptr = uri.ptr;
	end = ptr + uri.len;

	/* RFC7230, par. 2.7 :
	 * Request-URI = "*" | absuri | abspath | authority
	 */

	if (*ptr == '*')
		goto not_found;

	if (isalpha((unsigned char)*ptr)) {
		/* this is a scheme as described by RFC3986, par. 3.1 */
		ptr++;
		while (ptr < end &&
		       (isalnum((unsigned char)*ptr) || *ptr == '+' || *ptr == '-' || *ptr == '.'))
			ptr++;
		/* skip '://' */
		if (ptr == end || *ptr++ != ':')
			goto not_found;
		if (ptr == end || *ptr++ != '/')
			goto not_found;
		if (ptr == end || *ptr++ != '/')
			goto not_found;
	}
	/* skip [user[:passwd]@]host[:[port]] */

	while (ptr < end && *ptr != '/')
		ptr++;

	if (ptr == end)
		goto not_found;

	/* OK, we got the '/' ! */
	return ist2(ptr, end - ptr);

 not_found:
	return ist2(NULL, 0);
}
Exemple #2
0
/*
 * returns a known method among HTTP_METH_* or HTTP_METH_OTHER for all unknown
 * ones.
 */
enum http_meth_t find_http_meth(const char *str, const int len)
{
	const struct ist m = ist2(str, len);

	if      (isteq(m, ist("GET")))     return HTTP_METH_GET;
	else if (isteq(m, ist("HEAD")))    return HTTP_METH_HEAD;
	else if (isteq(m, ist("POST")))    return HTTP_METH_POST;
	else if (isteq(m, ist("CONNECT"))) return HTTP_METH_CONNECT;
	else if (isteq(m, ist("PUT")))     return HTTP_METH_PUT;
	else if (isteq(m, ist("OPTIONS"))) return HTTP_METH_OPTIONS;
	else if (isteq(m, ist("DELETE")))  return HTTP_METH_DELETE;
	else if (isteq(m, ist("TRACE")))   return HTTP_METH_TRACE;
	else                               return HTTP_METH_OTHER;
}
Exemple #3
0
int main()
{
	vector<string>reading;   //╤ахКнд╪Ч╣ддзхщ
	cout << "Please enter input file name: ";
	string name1;
	cin >> name1;
	ifstream ist1(name1.c_str());
	if (!ist1)
	{
		cout << "someting was wrong" << endl;
		getchar();
		getchar();
		getchar();
	}
	else
	{
		try                                       //╡Бйтйг╥ЯспрЛЁё
		{
			fill_vector(ist1, reading);
		}
		catch (error)
		{
			cout << "something is wrong" << endl;
			return 0;
		}
		cout << "Please enter another input file name: ";
		string name2;
		cin >> name2;
		ifstream ist2(name2.c_str());
		if (!ist2)
		{
			cout << "someting was wrong" << endl;
			getchar();
			getchar();
			getchar();
		}
		else
		{
			try
			{
				fill_vector(ist2, reading);
			}
			catch (error)
			{
				cout << "something is wrong" << endl;
				getchar();
				getchar();
				getchar();
			}
			for (int i = 0; i < reading.size(); i++)
			{
				check.push_back(reading[i]);
			}
			for (int i = 0; i < check.size(); i++)
			{
				tolower(check[i]);
			}
			
			BubbleSort(reading);             //еепР
			cout << "Please enter name of output file: ";       //йДЁЖ
			string name3;
			cin >> name3;
			ofstream ofs(name3.c_str());
			if (!ofs)
			{
				cout << "someting was wrong" << endl;
				getchar();
				getchar();
				getchar();
			}
			else
			{
				for (int i = 0; i < reading.size(); i++)
				{
					ofs << reading[i] << ' ';
				}
			}
		}

		}
		
	
	getchar();
	getchar();
	getchar();


}