[users@httpd] output_filter apr_bucket_read
I am working on output_filter I have question about reading data. I am reading data with similar technic like mod_dumpio, but when testing with large pdf file, I have less data in apr_bucket_read , then b-length indicates. It seems some buffer size limit for reading exists. how should I get all data out of b? any existing example ? (I am not manipulating data in buckets at all, just forwarding them to next filter). for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) { apr_size_t bsize = b-length; if (!(APR_BUCKET_IS_METADATA(b))) { if (apr_bucket_read(b, buf, nbytes, APR_BLOCK_READ) == APR_SUCCESS) { if (nbytes) { do something with buf } } } } printout of buckets: (data-HEAP as b-length): 254 bytes nbytes:254 (data-FILE): 11563137 bytes length from nbytes:4194304 (data-FILE): 7368833 bytes length from nbytes:4194304 (data-FILE): 3174529 bytes length from nbytes:3174529 mod_ta: (metadata-EOS): 0 bytes thanks, Lyudmila - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
[users@httpd] apache filter flush bucket chunked
Hello, I am writing some output filter and I am studying existing code. I need to create socket in my code and read data from buckets and send data using chunking encoring. So my question if I need to do any special processing with flush buckets, besides forwarding them to next filter. example below is from chunk_filter.c When doing chunking encoding why CRLF needs to be inserted before flush bucket, Is it just metadata bucket you skip ? * Insert the end-of-chunk CRLF before an EOS or * FLUSH bucket, or appended to the brigade */ e = apr_bucket_immortal_create(ASCII_CRLF, 2, c-bucket_alloc); if (eos != NULL) { APR_BUCKET_INSERT_BEFORE(eos, e); } else if (flush != NULL) { APR_BUCKET_INSERT_BEFORE(flush, e); } thanks, Lyudmila - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [users@httpd] apache filter flush bucket chunked
Could you comment on my question. I am aware of modular architecture. I need to send data to different server for archiving with each request. On Fri, 7 Oct 2011 11:08:03 -0600 (MDT) Lyudmila L. Balakireva lu...@lanl.gov wrote: Hello, I am writing some output filter and I am studying existing code. I need to create socket in my code and read data from buckets and send data using chunking encoring. You probably DON'T want to do that in your module. Just pass your data down the chain and let the builtin chunking filter chunk them. You're working in a modular architecture. Don't reinvent the wheel! -- Nick Kew - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
[users@httpd] logging from custom module ubuntu apache
Hello, I installed apache 2.2.17 on ubuntu. I also added custom module which has debug messages such as: ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,mod_xxx: uri from cache check %s,val) ; etc On Red Hat apache the module is logging to error.log, but on ubuntu apache it does not. Is anything in configuration need to be changed or additional module needs to be installed to achieve logging? I have LogLevel debug set in module config. Thanks for help, Lyudmila - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
[us...@httpd] url of internal redirect
Hi, I have output filter at AP_FTYPE_CONNECTION - 1 moment : ap_register_output_filter(MY_TA_OUT3, ta_out_filter3,NULL, AP_FTYPE_CONNECTION - 1); and I determine the url of request as const char *uri = r-unparsed_uri; but we have site with does redirect from www.company.org/ to www.company.org/index.htm the url I am getting is www.company.org/ not www.company.org/index.htm inside the filter. Is it possible to record final uri of serving? Thank you, Luda - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [us...@httpd] how to do http PUT inside the output filter
On 17 Jun 2009, at 18:52, Lyudmila L. Balakireva wrote: Hello, I am new to apache and c and Then you're probably being over-ambitious :-) One thing that immediately stands out: you're using the request pool, but you defined your filter to run outside the protocol level, where the request object (and hence its pool) is no longer valid. The simple fix would be to use the connection pool. But that in turn highlights the likelihood that you might want to revisit your architectural design. thank you for you reply, though the fact that I am using request when it is no longer valid, already occurred to me yesterday, could you tell more what you mean But that in turn highlights the likelihood that you might want to revisit your architectural design. ... ? Do I need to move to AP_FTYPE_RESOURCE filter or you mean overall approach is not valid (opening socket per request for example is not good)? Thanks, Luda -- Nick Kew Application Development with Apache - the Apache Modules Book http://www.apachetutor.org/ - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
[us...@httpd] how to do http PUT inside the output filter
Hello, I am new to apache and c and need help in developing output filter which need to collect (headers and body ) and send PUT request to external webserver. Currently I am getting child pid 7106 exit signal Segmentation fault (11) error in my filter: Can somebody pinpoint if I do something fundamentally wrong, my code snippet: #include httpd.h #include http_connection.h #include http_config.h #include http_core.h #include http_log.h #include apr_strings.h #include apr_tables.h #define HEADEREND CRLF CRLF char *authHost = localhost; static const char *const tabaseurl= http://localhost:8080/;; typedef struct { apr_socket_t *sock; } s_ctx; static int logError(apr_status_t status, char *message, request_rec *request) { ap_log_rerror(APLOG_MARK, APLOG_ERR, status, request, ta_put: error %s, message); return HTTP_SERVICE_UNAVAILABLE; } static int ta_filter_init(ap_filter_t* f) { request_rec *r = f-r; //apr_socket_t *sock; apr_sockaddr_t *sockaddr; apr_status_t status; apr_interval_time_t timeout = 500; conn_rec *c = f-c; struct iovec vec[1]; apr_size_t len; char *authRequest; authRequest = apr_pstrcat(r-pool, PUT , tabaseurl, /HTTP/1.1,CRLF,Host: , authHost, CRLF, Content-Length: 0, CRLF, Connection: close,HEADEREND); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c-base_server, mod_tafilter1: in the init 2 filter function) ; s_ctx* sctx = f-ctx = apr_pcalloc(r-pool, sizeof(s_ctx)); if ((status = apr_sockaddr_info_get(sockaddr, authHost, APR_INET, 8080, 0, r-pool)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c-base_server,tafiltert1:problem creating socket address ) ; return logError(status, creating socket address, r); } if ((status = apr_socket_create((sctx-sock), sockaddr-family, SOCK_STREAM, APR_PROTO_TCP, r-pool)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c-base_server,tafiltert1:problem creating socket ) ; return logError(status, creating socket, r); } // apr_socket_opt_set( s, APR_SO_NONBLOCK, 1 ); if ((status = apr_socket_timeout_set(sctx-sock, timeout)) != APR_SUCCESS) { return logError(status, setting socket timeout, r); } if ((status = apr_socket_connect(sctx-sock, sockaddr)) != APR_SUCCESS) { return logError(status, connecting, r); } apr_size_t item_size = strlen(authRequest); vec[0].iov_base = authRequest; vec[0].iov_len = item_size; status = apr_socket_sendv(sctx-sock, vec, 1, len); if (status != APR_SUCCESS) { return logError(status, sending header data, r); } return OK ; } static apr_status_t ta_out_filter(ap_filter_t *f,apr_bucket_brigade *bb){ request_rec *r = f-r; //apr_socket_t *sock; //apr_sockaddr_t *sockaddr; apr_status_t status; //apr_interval_time_t timeout = 500; //char *authRequest; conn_rec *c = f-c; apr_size_t len; apr_bucket* b; struct iovec vec[1]; ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c-base_server, mod_tafilter1: in the output filter function) ; s_ctx* sctx = (s_ctx*) f-ctx; if (sctx == NULL) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c-base_server, mod_tafilter1: in the init filter function) ; ta_filter_init(f) ; //sctx = f-ctx ; } for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, c-base_server, tafiltert1: %s (%s-%s): % APR_SIZE_T_FMT bytes, f-frec-name, (APR_BUCKET_IS_METADATA(b)) ? metadata : data, b-type-name, b-length) ; if (APR_BUCKET_IS_EOS(b)) { char * end = apr_pstrcat(r-pool,NULL); vec[0].iov_base = end; vec[0].iov_len = sizeof(end); status = apr_socket_sendv(sctx-sock, vec, 1, len); // if (status != APR_SUCCESS) { // logError(status, sending eof, r); //} apr_socket_close(sctx-sock); } if (!(APR_BUCKET_IS_METADATA(b))) { const char *buff; apr_size_t nbytes; if (apr_bucket_read(b, buff, nbytes, APR_BLOCK_READ) == APR_SUCCESS) { vec[0].iov_base = buff; vec[0].iov_len = nbytes; status = apr_socket_sendv(sctx-sock, vec, 1, len);
[us...@httpd]
Hello, I need to supply different content handler based on presence of certain request header. Is it any simple ready to use solution exists for the problem? Like configuration direction (example please). Or I need to implement input filter to check header and set the content handler ? any examples for this? Any help will be appreciated, Luda - The official User-To-User support forum of the Apache HTTP Server Project. See URL:http://httpd.apache.org/userslist.html for more info. To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org from the digest: users-digest-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org