示例#1
0
//parse_hier_part_case = "//" authority path-abempty
TextCursor parse_hier_part_case(TextCursor cursor)
{
    if (get_char(cursor) != '/')
        throw ParseError();
    if (get_char(cursor) != '/')
        throw ParseError();
    cursor = parse_authority(cursor);
    return parse_path_abempty(cursor);
}
示例#2
0
文件: URI.cpp 项目: kurocha/dream
				static IteratorT parse_hierarchy(IteratorT begin, IteratorT end, Hierarchy & hierarchy) {
					// (//([^/?#]*))?
					IteratorT authority_begin = parse_constant("//", begin, end);
					IteratorT authority_end = authority_begin;

					if (authority_begin != begin) {
						authority_end = parse_authority(authority_begin, end, hierarchy.authority);

						hierarchy.authority_begin = authority_begin;
						hierarchy.authority_end = authority_end;
					}

					// ([^?#]*)
					hierarchy.path_begin = authority_end;
					hierarchy.path_end = parse_path(hierarchy.path_begin, end);

					return hierarchy.path_end;
				}
示例#3
0
文件: uri.c 项目: graingert/6share
uri_t* parse_uri(char* uri_string, int len) {

	uri_t* uri = NULL;
	char* tmp_uri = NULL;
	char* uri_pointer = NULL;

	if(!(tmp_uri = (char*)calloc((strlen(uri_string) + 1), sizeof(char)))) {
		printf("Could not alloc memory for tmp (uri string)!\n");
		return NULL;
	}

	memcpy(tmp_uri, uri_string, strlen(uri_string));

	if(!(uri = (uri_t*)calloc(1, sizeof(uri_t)))) {
		printf("Could not alloc memory for uri structure!\n");
		free(tmp_uri);
		return NULL;
	}

	uri_pointer = parse_scheme(uri, tmp_uri);

	if(strcmp(uri_pointer, uri_string) == 0) {
	
		uri_pointer = parse_path(uri, uri_pointer);
		
		if(uri_pointer != NULL) {
			uri_pointer = parse_frag(uri, uri_pointer);
		}
	}
	else {
		uri_pointer = parse_authority(uri, uri_pointer);
		uri_pointer = parse_path(uri, uri_pointer);

		if(uri_pointer != NULL) {
			uri_pointer = parse_frag(uri, uri_pointer);
		}
	}

	free(tmp_uri);
	return uri;
}
示例#4
0
bool http_request_headers_finalize(http_request_t * const request) {
  header_list_t * header_list = request->headers;
  if (header_list) {

    char * method = http_request_header_get(request, ":method");

    if (!method) {
      log_append(request->log, LOG_ERROR, "Missing :method header");
      return NULL;
    }

    request->method = strdup(method);

    char * scheme = http_request_header_get(request, ":scheme");

    if (!scheme) {
      log_append(request->log, LOG_ERROR, "Missing :scheme header");
      return NULL;
    }

    request->scheme = strdup(scheme);

    if (!parse_path(request)) {
      return NULL;
    }

    parse_authority(request);
    parse_parameters(request->params, request->query_string);

    header_list_remove_pseudo_headers(header_list);

  } else {
    request->headers = header_list_init(NULL);
  }

  return request;
}