]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/testhttp.c
Updated configure script to set PAMDIR when PAM is enabled.
[thirdparty/cups.git] / cups / testhttp.c
CommitLineData
04c3c0a1 1/*
71fe22b7 2 * "$Id: testhttp.c,v 1.8 2000/01/04 13:45:37 mike Exp $"
04c3c0a1 3 *
4 * HTTP test program for the Common UNIX Printing System (CUPS).
5 *
71fe22b7 6 * Copyright 1997-2000 by Easy Software Products.
04c3c0a1 7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
8784b6a6 17 * 44141 Airport View Drive, Suite 204
04c3c0a1 18 * Hollywood, Maryland 20636-3111 USA
19 *
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * Contents:
25 *
26 * main() - Main entry.
27 */
28
29/*
30 * Include necessary headers...
31 */
32
3b960317 33#include <stdio.h>
04c3c0a1 34#include "http.h"
35
36
37/*
38 * 'main()' - Main entry.
39 */
40
0542e38e 41int /* O - Exit status */
42main(int argc, /* I - Number of command-line arguments */
43 char *argv[]) /* I - Command-line arguments */
04c3c0a1 44{
0542e38e 45 int i; /* Looping var */
46 http_t *http; /* HTTP connection */
47 http_status_t status; /* Status of GET command */
48 char buffer[1024]; /* Input buffer */
49 int bytes; /* Number of bytes read */
0d1f75a3 50 FILE *out; /* Output file */
0542e38e 51
b87e43e9 52#define HOST "dns.easysw.com"
53#define PORT 80
0542e38e 54
9ae9d67c 55 puts("Connecting to " HOST "...");
0542e38e 56
57 httpInitialize();
9ae9d67c 58 http = httpConnect(HOST, PORT);
0542e38e 59 if (http == NULL)
60 {
9ae9d67c 61 puts("Unable to connect to " HOST "!");
0542e38e 62 return (1);
63 }
64
9ae9d67c 65 puts("Connected to " HOST "...");
0542e38e 66
0d1f75a3 67 out = stdout;
68
0542e38e 69 for (i = 1; i < argc; i ++)
70 {
0d1f75a3 71 if (strcmp(argv[i], "-o") == 0)
72 {
73 i ++;
74 out = fopen(argv[i], "wb");
75 continue;
76 }
77
0542e38e 78 printf("Requesting file \"%s\"...\n", argv[i]);
79 httpClearFields(http);
9ae9d67c 80 httpSetField(http, HTTP_FIELD_ACCEPT_LANGUAGE, "en");
0542e38e 81 httpGet(http, argv[i]);
82 status = httpUpdate(http);
83
84 if (status == HTTP_OK)
85 puts("GET OK:");
86 else
87 printf("GET failed with status %d...\n", status);
88
89 while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0)
0d1f75a3 90 {
91 fwrite(buffer, bytes, 1, out);
92 if (out != stdout)
93 printf("Read %d bytes, %d total...\n", bytes, ftell(out));
94 }
0542e38e 95 }
96
97 puts("Closing connection to server...");
98 httpClose(http);
99
0d1f75a3 100 if (out != stdout)
101 fclose(out);
102
0542e38e 103 return (0);
04c3c0a1 104}
105
106
107/*
71fe22b7 108 * End of "$Id: testhttp.c,v 1.8 2000/01/04 13:45:37 mike Exp $".
04c3c0a1 109 */