|
@@ -40,7 +40,6 @@
|
40
|
40
|
#include <gpxe/tcpip.h>
|
41
|
41
|
#include <gpxe/process.h>
|
42
|
42
|
#include <gpxe/linebuf.h>
|
43
|
|
-#include <gpxe/tls.h>
|
44
|
43
|
#include <gpxe/http.h>
|
45
|
44
|
|
46
|
45
|
/** HTTP receive state */
|
|
@@ -459,13 +458,18 @@ static struct xfer_interface_operations http_xfer_operations = {
|
459
|
458
|
};
|
460
|
459
|
|
461
|
460
|
/**
|
462
|
|
- * Initiate an HTTP connection
|
|
461
|
+ * Initiate an HTTP connection, with optional filter
|
463
|
462
|
*
|
464
|
463
|
* @v xfer Data transfer interface
|
465
|
464
|
* @v uri Uniform Resource Identifier
|
|
465
|
+ * @v default_port Default port number
|
|
466
|
+ * @v filter Filter to apply to socket, or NULL
|
466
|
467
|
* @ret rc Return status code
|
467
|
468
|
*/
|
468
|
|
-static int http_open ( struct xfer_interface *xfer, struct uri *uri ) {
|
|
469
|
+int http_open_filter ( struct xfer_interface *xfer, struct uri *uri,
|
|
470
|
+ unsigned int default_port,
|
|
471
|
+ int ( * filter ) ( struct xfer_interface *xfer,
|
|
472
|
+ struct xfer_interface **next ) ) {
|
469
|
473
|
struct http_request *http;
|
470
|
474
|
struct sockaddr_tcpip server;
|
471
|
475
|
struct xfer_interface *socket;
|
|
@@ -487,11 +491,10 @@ static int http_open ( struct xfer_interface *xfer, struct uri *uri ) {
|
487
|
491
|
|
488
|
492
|
/* Open socket */
|
489
|
493
|
memset ( &server, 0, sizeof ( server ) );
|
490
|
|
- server.st_port = htons ( uri_port ( http->uri, HTTP_PORT ) );
|
|
494
|
+ server.st_port = htons ( uri_port ( http->uri, default_port ) );
|
491
|
495
|
socket = &http->socket;
|
492
|
|
- if ( strcmp ( http->uri->scheme, "https" ) == 0 ) {
|
493
|
|
- server.st_port = htons ( uri_port ( http->uri, HTTPS_PORT ) );
|
494
|
|
- if ( ( rc = add_tls ( socket, &socket ) ) != 0 )
|
|
496
|
+ if ( filter ) {
|
|
497
|
+ if ( ( rc = filter ( socket, &socket ) ) != 0 )
|
495
|
498
|
goto err;
|
496
|
499
|
}
|
497
|
500
|
if ( ( rc = xfer_open_named_socket ( socket, SOCK_STREAM,
|
|
@@ -512,14 +515,19 @@ static int http_open ( struct xfer_interface *xfer, struct uri *uri ) {
|
512
|
515
|
return rc;
|
513
|
516
|
}
|
514
|
517
|
|
|
518
|
+/**
|
|
519
|
+ * Initiate an HTTP connection
|
|
520
|
+ *
|
|
521
|
+ * @v xfer Data transfer interface
|
|
522
|
+ * @v uri Uniform Resource Identifier
|
|
523
|
+ * @ret rc Return status code
|
|
524
|
+ */
|
|
525
|
+static int http_open ( struct xfer_interface *xfer, struct uri *uri ) {
|
|
526
|
+ return http_open_filter ( xfer, uri, HTTP_PORT, NULL );
|
|
527
|
+}
|
|
528
|
+
|
515
|
529
|
/** HTTP URI opener */
|
516
|
530
|
struct uri_opener http_uri_opener __uri_opener = {
|
517
|
531
|
.scheme = "http",
|
518
|
532
|
.open = http_open,
|
519
|
533
|
};
|
520
|
|
-
|
521
|
|
-/** HTTPS URI opener */
|
522
|
|
-struct uri_opener https_uri_opener __uri_opener = {
|
523
|
|
- .scheme = "https",
|
524
|
|
- .open = http_open,
|
525
|
|
-};
|