author | harlekin <harlekin> | 2002-04-20 21:23:38 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-20 21:23:38 (UTC) |
commit | 679083ca18ddbf4762578d1aa010203ea188586c (patch) (unidiff) | |
tree | eada9fcd708aedbbe8c6ef207942125ce4ad97a9 | |
parent | b452044ec1b3327f25f8552045b4229c8af39bf7 (diff) | |
download | opie-679083ca18ddbf4762578d1aa010203ea188586c.zip opie-679083ca18ddbf4762578d1aa010203ea188586c.tar.gz opie-679083ca18ddbf4762578d1aa010203ea188586c.tar.bz2 |
no / needed at the url end
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 4665408..7978805 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp | |||
@@ -215,82 +215,85 @@ int LibMadPlugin::tcp_open(char *address, int port) { | |||
215 | /** | 215 | /** |
216 | * Read a http line header. | 216 | * Read a http line header. |
217 | * This function read character by character. | 217 | * This function read character by character. |
218 | * @param tcp_sock the socket use to read the stream | 218 | * @param tcp_sock the socket use to read the stream |
219 | * @param buf a buffer to receive the data | 219 | * @param buf a buffer to receive the data |
220 | * @param size size of the buffer | 220 | * @param size size of the buffer |
221 | * @return the size of the stream read or -1 if an error occured | 221 | * @return the size of the stream read or -1 if an error occured |
222 | */ | 222 | */ |
223 | int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) { | 223 | int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) { |
224 | int offset = 0; | 224 | int offset = 0; |
225 | 225 | ||
226 | do | 226 | do |
227 | { | 227 | { |
228 | if (std::read(tcp_sock, buf + offset, 1) < 0) | 228 | if (std::read(tcp_sock, buf + offset, 1) < 0) |
229 | return -1; | 229 | return -1; |
230 | if (buf[offset] != '\r') /* Strip \r from answer */ | 230 | if (buf[offset] != '\r') /* Strip \r from answer */ |
231 | offset++; | 231 | offset++; |
232 | } | 232 | } |
233 | while (offset < size - 1 && buf[offset - 1] != '\n'); | 233 | while (offset < size - 1 && buf[offset - 1] != '\n'); |
234 | 234 | ||
235 | buf[offset] = 0; | 235 | buf[offset] = 0; |
236 | return offset; | 236 | return offset; |
237 | } | 237 | } |
238 | 238 | ||
239 | int LibMadPlugin::http_open(const QString& path ) { | 239 | int LibMadPlugin::http_open(const QString& path ) { |
240 | qDebug("Open http"); | 240 | qDebug("Open http"); |
241 | char *host; | 241 | char *host; |
242 | int port; | 242 | int port; |
243 | char *request; | 243 | char *request; |
244 | int tcp_sock; | 244 | int tcp_sock; |
245 | char http_request[PATH_MAX]; | 245 | char http_request[PATH_MAX]; |
246 | char filename[PATH_MAX]; | 246 | char filename[PATH_MAX]; |
247 | char c; | 247 | // char c; |
248 | char *arg =strdup(path.latin1()); | 248 | char *arg =strdup(path.latin1()); |
249 | 249 | ||
250 | QString errorMsg; | 250 | QString errorMsg; |
251 | 251 | ||
252 | /* Check for URL syntax */ | 252 | /* Check for URL syntax */ |
253 | // if (strncmp(arg, "http://", strlen("http://"))) { | 253 | // if (strncmp(arg, "http://", strlen("http://"))) { |
254 | // qDebug("Url syntax error"); | 254 | // qDebug("Url syntax error"); |
255 | // return (0); | 255 | // return (0); |
256 | // } | 256 | // } |
257 | 257 | ||
258 | qDebug("Parse URL"); | 258 | qDebug("Parse URL"); |
259 | port = 80; | 259 | port = 80; |
260 | host = arg + strlen("http://"); | 260 | host = arg + strlen("http://"); |
261 | if ((request = strchr(host, '/')) == NULL) { | 261 | |
262 | qDebug("Url syntax 2error %s", host); | 262 | // we need to think of something better than that |
263 | return (0); | 263 | //if ((request = strchr(host, '/')) == NULL) { |
264 | } | 264 | // qDebug("Url syntax 2error %s", host); |
265 | // return (0); | ||
266 | // } | ||
267 | |||
265 | *request++ = 0; | 268 | *request++ = 0; |
266 | 269 | ||
267 | if (strchr(host, ':') != NULL) /* port is specified */ | 270 | if (strchr(host, ':') != NULL) /* port is specified */ |
268 | { | 271 | { |
269 | port = atoi(strchr(host, ':') + 1); | 272 | port = atoi(strchr(host, ':') + 1); |
270 | *strchr(host, ':') = 0; | 273 | *strchr(host, ':') = 0; |
271 | } | 274 | } |
272 | 275 | ||
273 | qDebug("Open a TCP socket"); | 276 | qDebug("Open a TCP socket"); |
274 | if (!(tcp_sock = tcp_open(host, port))) { | 277 | if (!(tcp_sock = tcp_open(host, port))) { |
275 | perror("http_open"); | 278 | perror("http_open"); |
276 | errorMsg="http_open "+(QString)strerror(errno); | 279 | errorMsg="http_open "+(QString)strerror(errno); |
277 | QMessageBox::message("OPiePlayer",errorMsg); | 280 | QMessageBox::message("OPiePlayer",errorMsg); |
278 | return (0); | 281 | return (0); |
279 | } | 282 | } |
280 | 283 | ||
281 | snprintf(filename, sizeof(filename) - strlen(host) - 75, "%s", request); | 284 | snprintf(filename, sizeof(filename) - strlen(host) - 75, "%s", request); |
282 | 285 | ||
283 | /* Send HTTP GET request */ | 286 | /* Send HTTP GET request */ |
284 | /* Please don't use a Agent know by shoutcast (Lynx, Mozilla) seems to be reconized and print | 287 | /* Please don't use a Agent know by shoutcast (Lynx, Mozilla) seems to be reconized and print |
285 | * a html page and not the stream */ | 288 | * a html page and not the stream */ |
286 | snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n" | 289 | snprintf(http_request, sizeof(http_request), "GET /%s HTTP/1.0\r\n" |
287 | /* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */ | 290 | /* "User-Agent: Mozilla/2.0 (Win95; I)\r\n" */ |
288 | "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host); | 291 | "Pragma: no-cache\r\n" "Host: %s\r\n" "Accept: */*\r\n" "\r\n", filename, host); |
289 | qDebug("send"); | 292 | qDebug("send"); |
290 | send(tcp_sock, http_request, strlen(http_request), 0); | 293 | send(tcp_sock, http_request, strlen(http_request), 0); |
291 | 294 | ||
292 | qDebug("Parse server reply"); | 295 | qDebug("Parse server reply"); |
293 | #if 0 | 296 | #if 0 |
294 | qDebug("do 0"); | 297 | qDebug("do 0"); |
295 | do | 298 | do |
296 | read(tcp_sock, &c, sizeof(char)); | 299 | read(tcp_sock, &c, sizeof(char)); |