Changes in uspace/lib/http/src/request.c [5a6cc679:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/http/src/request.c
r5a6cc679 ra35b458 52 52 if (req == NULL) 53 53 return NULL; 54 54 55 55 req->method = str_dup(method); 56 56 if (req->method == NULL) { … … 58 58 return NULL; 59 59 } 60 60 61 61 req->path = str_dup(path); 62 62 if (req->path == NULL) { … … 65 65 return NULL; 66 66 } 67 67 68 68 http_headers_init(&req->headers); 69 69 70 70 return req; 71 71 } … … 98 98 return EINVAL; 99 99 size_t size = meth_size; 100 100 101 101 http_headers_foreach(req->headers, header) { 102 102 ssize_t header_size = http_header_encode(header, NULL, 0); … … 106 106 } 107 107 size += str_length(HTTP_REQUEST_LINE); 108 108 109 109 char *buf = malloc(size); 110 110 if (buf == NULL) 111 111 return ENOMEM; 112 112 113 113 char *pos = buf; 114 114 size_t pos_size = size; … … 120 120 pos += written; 121 121 pos_size -= written; 122 122 123 123 http_headers_foreach(req->headers, header) { 124 124 written = http_header_encode(header, pos, pos_size); … … 130 130 pos_size -= written; 131 131 } 132 132 133 133 size_t rlsize = str_size(HTTP_REQUEST_LINE); 134 134 memcpy(pos, HTTP_REQUEST_LINE, rlsize); 135 135 pos_size -= rlsize; 136 136 assert(pos_size == 0); 137 137 138 138 *out_buf = buf; 139 139 *out_buf_size = size; … … 145 145 char *buf = NULL; 146 146 size_t buf_size = 0; 147 147 148 148 errno_t rc = http_request_format(req, &buf, &buf_size); 149 149 if (rc != EOK) 150 150 return rc; 151 151 152 152 rc = tcp_conn_send(http->conn, buf, buf_size); 153 153 free(buf); 154 154 155 155 return rc; 156 156 }
Note:
See TracChangeset
for help on using the changeset viewer.